sanssan
sanssan

Reputation: 335

JBoss 7.1.1.Final - Log4j - EAR File application - Logging not working

Friends,

I found few details about the log4j configuration.

We do have few application already running on JBoss 3.x and I am migrating them to JBoss 7.1.1.Final.

Few of the WAR file, JAR files and EAR files. I found some documents to configure the Log4j within JBoss.

It worked great with WAR files. Still, I couldn't make it work on EAR files.

MyApp.ear
    |
    |- META-INF
        |
        |- application.xml
        |- jboss-deployment-structure.xml
    |
    |- lib
        |
        |- *.jar
    |
    |- MyApp1.war
        |- lib
            |
            |- *.jar
        |- WEB-INF
            |
            |- server-config.wsdd
            |- web.xml
            |- classes
    |
    |- MyApp2.war
        |- WEB-INF
            |
            |- ApplicationResources.properties
            |- web.xml
            |- classes
    |
    |- MyApp.jar
        |
        |- META-INF
            |- jboss-service.xml
            |- jboss.xml
        |- com

I can't use JBoss logging because it is a big application and all classes using Log4j. Now, what is the best place for log4j.properties?

I can have all EAR classes Logging to 1 configuration....

log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.File=./../standalone/log/quote.log
log4j.appender.file.MaxFileSize=2000KB
log4j.appender.file.MaxBackupIndex=60
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss.SSS} [%-5p] - %C{1} - %m%n
log4j.appender.file.Append=false

log4j.rootCategory=DEBUG, file

Please advise me....

Upvotes: 1

Views: 1245

Answers (1)

James R. Perkins
James R. Perkins

Reputation: 17780

From the looks of your log4j.properties there appears to be no real need for it. You can configure the logging subsystem to do what you're already doing and continue to use log4j as your logging facade.

The equivalent to a DailyRotatingFileAppender would be the periodic-rotating-file-handler. The one thing the periodic-rotating-file-handler doesn't do is allow a size and the number of files to retain. It would be fairly easy to add a new handler though.

<periodic-rotating-file-handler name="quote" autoflush="true">
    <formatter>
        <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="quote.log"/>
    <suffix value=".yyyy-MM-dd"/>
    <append value="false"/>
</periodic-rotating-file-handler>

Upvotes: 0

Related Questions