JBoss, by current design, only provides for one logging context (ie
LoggerRepository).  On top of that, the JBoss log4j.xml also sets up a
special CONSOLE appender that maps the System.out and System.err streams.

If you do any kind of configuration after JBoss starts up that affects the
console appender OR affects loggers that have been defined in the JBoss
log4j.xml file, then it will affect the output to the log files.  Especially
Console, do not mess with Console.  Also, if your log4j code ever calls
LoggerRepository.shutdown() during a redeploy, then logging will be hosed as
well.

JBoss really needs to provide a better mechanism to allowing web apps and
ejb's to do their own logging.

Log4j does provide some "layering" of configuration where you can set up
your own loggers and appenders as long as they are not references by the
first/base configuration file.  Or you can just add your logging stuff to
the JBoss log4j.xml file directly.

You may also find the following link useful, but I don't know if anyone has
gotten to work correctly in JBoss or not.  Seems to me that to be completely
efficient, it would need to be supported pretty deep in the JBoss log4j
initialization.

http://www.qos.ch/logging/sc.jsp

-Mark


> -----Original Message-----
> From: Clandes Tino [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 16, 2005 6:51 AM
> To: log4j-user@logging.apache.org
> Subject: log4j stops logging at console
> 
> Hello all.
> I am facing the problem with log4j usage in two
> separate applications.
> I am using CONSOLE appenders for both of them.
> Applications are started separately (in two shell
> windows). The first app (App1) is assembled as EAR and
> deployed under JBoss (it uses log4j.jar from
> JBoss/server/default/lib and initializes log4j through
> MBean, where appenders and loggers are configured).
> 
> Here is the method in MBean that configures log4j in
> App1:
> -------------------------------------------------------
> private void initLog4j() throws ConfigurationException
> {
>     final Properties props = new Properties();
>     props.setProperty("log4j.category.com.myapp",
> "DEBUG, CONSOLE, FILE");
> 
> props.setProperty("log4j.appender.CONSOLE","org.apache.log4j.ConsoleAppend
> er");
> props.setProperty("log4j.appender.CONSOLE.layout","org.apache.log4j.Patter
> nLayout")
> 
> props.setProperty("log4j.appender.CONSOLE.layout.ConversionPattern","%d{IS
> O8601}
>  %-5p [%c{1}] [%X{user}]  - %m%n");
> 
> props.setProperty("log4j.appender.FILE","org.apache.log4j.RollingFileAppen
> der");
> 
> props.setProperty("log4j.appender.FILE.File",
> getConfigurationSetting(LOG_FILE));
> 
> props.setProperty("log4j.appender.FILE.MaxFileSize",
> getConfigurationSetting(MAX_FILE_SIZE));
> 
> props.setProperty("log4j.appender.FILE.MaxBackupIndex",
> getConfigurationSetting(MAX_BACKUP_FILE));
> 
> props.setProperty("log4j.appender.FILE.layout","org.apache.log4j.PatternLa
> yout");
> 
> props.setProperty("log4j.appender.FILE.layout.ConversionPattern","%d{ISO86
> 01}
>  %-5p [%c{1}] [%X{user} %X{ip} %X{userAgent}] -
> %m%n");
> 
>         PropertyConfigurator.configure(props);
>      }
> 
> App1 uses A.jar and B.jar from App2 in compilation and
> runtime. Both jars are placed in sar archive and
> deployed in default/deploy folder under Jboss.
> 
> The other (App2) is RMI Server application deployed
> separately (it uses another log4j-1.2.8.jar placed in
> its classpath). A.jar and B.jar are in its classpath.
> App2 configures log4j by log4j properties file:
> 
> ------------------------------------------------
> log4j.category.CONSOLE = , aCONSOLE
> log4j.appender.aCONSOLE =
> org.apache.log4j.ConsoleAppender
> log4j.additivity.CONSOLE=false
> log4j.appender.aCONSOLE.ImmediateFlush=true
> log4j.appender.aCONSOLE.layout=org.apache.log4j.PatternLayout
> --------------------------------------------------
> 
> Both applications are physically on the same machine.
> The problem occurs when some class from App1 invokes a
> class from B.jar. Then logging disappears from console
>  window of App1. No further message in log appears.
> However logging into file works OK.
> 
> My question is:
> What can cause such behavior?
> 
> Thanx for the hint in advance.
> Best regards
> Milan
> 
> 
> 
> 
> ___________________________________________________________
> How much free photo storage do you get? Store your holiday
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to