Log4j not logging anything in application log file

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

I am trying to log the applications logs in
/var/lib/stickshift/<app Id>/<app name>/logs/<log file name>.log

Everything seems to work OK on the local environment (with different path of course) but don't see anything on the openshift/remote server. Even an empty log file has not been created as if the log4j.xml is not being read.

Am I missing something? Or does someone has standard steps to perform log4j application logging in a dedicated file?

Hi @SS2000;

Can you post your log4j configuration? Also, can you describe your app (e.g, app type, app URL, short description of functionality - for context)? I'd like to reproduce and try some things.

Thanks; ~Nam

Hi Nam, Here is log4j at the bottom. The application is a Java Web module with local EJBs, JSF and Rest. The URL (beta version so don't laugh): https://2ndclk-breakglass.rhcloud.com/iregister/faces/index.xhtml Functionality: Interaction is mainly on JSF pages and Rest. Logic is in stateless EJB where most of the logging is being performed. I have wrapped Log4j under SLF4J (all jars are in the lib folder) . File log4j.xml is directly under WEB-INF/classes and works well on local JBoss.

Here is an example of calling code:

Logger LOG = LoggerFactory.getLogger(InfoOwnerRegisterEjb.class); LOG.info("xxxxx");

<logger name="com.iregister">
    <level value="trace"/>
</level></logger>

<root>
    <priority value="info" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE" />
</appender-ref></appender-ref></priority></root>

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true" >

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

<layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %5p %c{2}: %m%n" />

</layout>

</appender>

<appender name="FILE" class="org.apache.log4j.RollingFileAppender">

<param name="File" value="/var/lib/stickshift/7016456f97c34cf29ca315234a9d502f/2ndclk/logs/2ndclk.log" />

<param name="MaxFileSize" value="1MB" />

<param name="MaxBackupIndex" value="100" />

<layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %5p %c{2}: %m%n" />

</layout>

</appender>

 

<logger name="com.iregister">

<level value="trace"/>

</logger>

 

<root>

<priority value="info" />

<appender-ref ref="CONSOLE" />

<appender-ref ref="FILE" />

</root>

</log4j:configuration>

Hi SS2000,

I'm testing your configuration now, but in the meantime have you tried just modifying the log config in standalone.xml?

Thanks -Bill

SS2000,

Per-deployment level logging (i.e. log4j.xml in your .war) is not supported until AS7.1.2 (https://issues.jboss.org/browse/AS7-514). So you have a couple options:

1) Migrate your application to EAP6.0 which is based on AS7.1.2 2) Implement your logging in the logging section of standalone.xml

You'll also need to add the following to your MANIFEST Dependencies: org.apache.log4j

We'll be upgrading the version of AS in OpenShift shortly.

Thanks -Bill