java - Confuguring log4j for multiple projects in the same app. server -
java - Confuguring log4j for multiple projects in the same app. server -
we have bunch of projects deployed in same jboss app. server. each project has own log4j.properties in web-inf directory.
the thought each project have own logfile writes logs.
any ideas on how can achieved.
first of don't mention jboss version you're using. you've take in mind jboss versions prior as7 include own log4j version (libraries , configuration file: conf/jboss-log4j.xml), default jboss ignore log4j.properties file you've in each of projects.
that said, have 2 approaches configure log file each application:
centralized way: configure in jboss, through conf/jboss-log4j.xml. way won't need modify applications, or modify applications take own log4j libraries (you'll have include them in ear/war), not jboss ones.for first approach you'll have define appender each of applications, , categories application packages, in conf/jboss-log4j.xml file. example, configure log file application called app1.war classes in bundle called com.foo.app1, you'd have add:
<appender name="app1_appender" class="org.jboss.logging.appender.dailyrollingfileappender"> <errorhandler class="org.jboss.logging.util.onlyonceerrorhandler"/> <param name="file" value="${jboss.server.log.dir}/app1.log"/> <param name="append" value="true"/> <!-- rollover @ midnight each day --> <param name="datepattern" value="'.'yyyy-mm-dd"/> <layout class="org.apache.log4j.patternlayout"> <!-- default pattern: date priority [category] (thread) message\n --> <param name="conversionpattern" value="%d %-5p [%c] (%t) %m%n"/> </layout> </appender> ... ... <category name="com.foo.app1" additivity="true"> <priority value="info"/> <appender-ref ref="app1_appender"/> </category>
you'll have add together customized set of blocks 1 each project want define log file for, respectively.
if prefer sec approach, said you'll have include log4j libraries in each project , isolate each application takes libraries included in application not ones jboss. look @ section 10.3.7 of jboss logging file more info approach.
java java-ee logging jboss log4j
Comments
Post a Comment