AW: Logging done in the wrong files
First: I do not know much about Jboss, especially not about the ordering of the classloader preferences. If your jar file is shared among all applications then the first initialized application wins (means executes as first the static code). You have to deploy the class with the static code into each application and ensure that Jboss loads child first (means first the application specific classloader searches for the class in the application class path, and only if not found the parent classloader searches in the global class path). Second: Although you call your logger wrapper "LogManager" it does not replace the built in LogManager of log4j. The log4j LogManager is still instantiated at the first time you call Logger.getLogger() or any configuration method of LogManager. In order to specify your own RepositorySelector initialize it somewhere at the start up of your application and call (log4j).LogManager.setRepositorySelector( myRepSel ). You have two ways to go: Either you get the classloading issues to work (have absolutely separate log4j universes). This includes deploying log4j.jar in each application along with the appropriate config file. Or: You write your own RepositorySelector, initialize and use it (and the log4j.jar) in the common scope. Going this way you have to find out a way how the RepositorySelector can distinguish the application context and provide the correct logger (each application has ist own loggers and appenders). The configuration is although a bit tricky: The common aspects (levels, logger-appender associations, layout, filters, etc.) can be done by a global config file, but the file name of a file appender must be provided at runtime depending on the application context. Choosing the second way there are other topics to be considered: Only classes which are unique to an application can have a static member for the logger instance. Classes shared among the applications (assuming an instance of this class is only used in one application) must have NON-STATIC Logger members. And helper classes with only static methods must call Logger.getLogger() in each method call again. Heri -Ursprüngliche Nachricht- Von: S.Kannan [mailto:techy_k...@yahoo.co.in] Gesendet: Mittwoch, 16. September 2009 14:15 An: log4j-user@logging.apache.org Betreff: RE: Logging done in the wrong files Thanks Brown for the reply. The following was the reply given by Bender Heri Your problem is a classloader issue. Keep in mind that the Logger-Universe which you initialize within your static method is globally the same within the same classloader. Annother classloader would initialize another logger-universe. You have to elaborate which class is loaded by which classloader. This depends on the application server you use, its configuration and your deployment. Search the archives for "MultiFileAppender" and "RepositorySelector". There are plenty of ideas how to separate log files depending on the context. The jboss app server gives an option like true which we have set as true. Thus different applications have different class loaders and from the reply of Bender i could understand that there are different logger-universe defined. Consider that The LogManager which i have mentioned earlier is in a jar file. This jar file is shared across all the EAR files. The log4j.properties file alone differs for each module. I could not figure out on how to use the RepositorySelector when my LogManager does not extend the log4j's LogManager . Any thoughts? -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25471153.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: AW: Logging done in the wrong files
Bender I tried the first solution. With the same log.properties file i get duplicate entries in the log files. Is it because there are two log4j.jar files or any other issue log4j.threshold=ALL log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug.txt log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout log4j.appender.DEBUG_APPENDER.layout.ConversionPattern=%d %-5p - %m%n log4j.appender.DEBUG_APPENDER.Append=false log4j.appender.DEBUG_APPENDER.Threshold=DEBUG log4j.appender.INFO_APPENDER=org.apache.log4j.RollingFileAppender log4j.appender.INFO_APPENDER.MaxBackupIndex=50 log4j.appender.INFO_APPENDER.MaxFileSize=10MB log4j.appender.INFO_APPENDER.file=data/tda/logs/Logger_Info.txt log4j.appender.INFO_APPENDER.layout=org.apache.log4j.PatternLayout log4j.appender.INFO_APPENDER.layout.ConversionPattern=%d %-5p - %m%n log4j.appender.INFO_APPENDER.Append=false log4j.appender.INFO_APPENDER.Threshold=INFO Thanks, Kannan.S -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25474093.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: AW: Logging done in the wrong files
Infact i tried using log4j.rootLogger.additivity=false but that has not solved the issue. I guess that is not the correct solution.. Trying still.. Kannan.S S.Kannan wrote: > > Bender > > I tried the first solution. With the same log.properties file i get > duplicate entries in the log files. > Is it because there are two log4j.jar files or any other issue > > log4j.threshold=ALL > log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER > > log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 > log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB > log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug.txt > log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.DEBUG_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.DEBUG_APPENDER.Append=false > log4j.appender.DEBUG_APPENDER.Threshold=DEBUG > > log4j.appender.INFO_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.INFO_APPENDER.MaxBackupIndex=50 > log4j.appender.INFO_APPENDER.MaxFileSize=10MB > log4j.appender.INFO_APPENDER.file=data/tda/logs/Logger_Info.txt > log4j.appender.INFO_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.INFO_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.INFO_APPENDER.Append=false > log4j.appender.INFO_APPENDER.Threshold=INFO > > Thanks, > Kannan.S > -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25475242.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: AW: Logging done in the wrong files
HI Kannan, i didnt still get the exact solution for my problem ,as you have suggested there may be two log4j,jar , where can i find this duplicates. Thanks & regards, Yogesh On Wed, Sep 16, 2009 at 8:20 PM, S.Kannan wrote: > > Bender > > I tried the first solution. With the same log.properties file i get > duplicate entries in the log files. > Is it because there are two log4j.jar files or any other issue > > log4j.threshold=ALL > log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER > > log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 > log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB > log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug.txt > log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.DEBUG_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.DEBUG_APPENDER.Append=false > log4j.appender.DEBUG_APPENDER.Threshold=DEBUG > > log4j.appender.INFO_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.INFO_APPENDER.MaxBackupIndex=50 > log4j.appender.INFO_APPENDER.MaxFileSize=10MB > log4j.appender.INFO_APPENDER.file=data/tda/logs/Logger_Info.txt > log4j.appender.INFO_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.INFO_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.INFO_APPENDER.Append=false > log4j.appender.INFO_APPENDER.Threshold=INFO > > Thanks, > Kannan.S > -- > View this message in context: > http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25474093.html > Sent from the Log4j - Users mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > >
AW: AW: Logging done in the wrong files
Additivity flag has no effect on root logger since the root logger is the uppermost logger within the hierarchy. The flag is only meant for subordinated loggers (e.g. com.my.company. ...). Do you have two log4j.jar in the same application? Each application needs only one (in WEB-INF/lib), and the parent classloader needs one (in common/lib). You say that you use "the same log.properties". Do you mean, you configure the same file names in two different applications? Therefore I guess you get the same entry from a common library class which is used by two different apps. Or do you mean you see, e.g., an INFO statement in both the Logger_Debug.txt and the Logger_Info.txt? This would be normal according to your configuration. Your copied config content is not complete. You reference an ERRRO_APPENDER which is not defined. Are you sure that there is no other logger declaration in your config file, without the additivity flag, but the same appenders? This would be the reason for having double log entries. Please explain more accurate. Heri -Ursprüngliche Nachricht- Von: S.Kannan [mailto:techy_k...@yahoo.co.in] Gesendet: Mittwoch, 16. September 2009 17:49 An: log4j-user@logging.apache.org Betreff: Re: AW: Logging done in the wrong files Infact i tried using log4j.rootLogger.additivity=false but that has not solved the issue. I guess that is not the correct solution.. Trying still.. Kannan.S S.Kannan wrote: > > Bender > > I tried the first solution. With the same log.properties file i get > duplicate entries in the log files. > Is it because there are two log4j.jar files or any other issue > > log4j.threshold=ALL > log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER > > log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 > log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB > log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug.txt > log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.DEBUG_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.DEBUG_APPENDER.Append=false > log4j.appender.DEBUG_APPENDER.Threshold=DEBUG > > log4j.appender.INFO_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.INFO_APPENDER.MaxBackupIndex=50 > log4j.appender.INFO_APPENDER.MaxFileSize=10MB > log4j.appender.INFO_APPENDER.file=data/tda/logs/Logger_Info.txt > log4j.appender.INFO_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.INFO_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.INFO_APPENDER.Append=false > log4j.appender.INFO_APPENDER.Threshold=INFO > > Thanks, > Kannan.S > -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25475242.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: AW: Logging done in the wrong files
HI , Actually , my problem is my log4j is not logging in a proper path, i.e its not taking the path defined in log4j.properties file.i have attached my log4j.properties file , and we are using custom log4j and we have added in a shared variable of WAS, all logs are getting in a WAS logs path with a short names , and also timestamp attached in the logs are wrong, Regards, Yogesh On Thu, Sep 17, 2009 at 12:16 PM, Bender Heri wrote: > Additivity flag has no effect on root logger since the root logger is the > uppermost logger within the hierarchy. The flag is only meant for > subordinated loggers (e.g. com.my.company. ...). > > Do you have two log4j.jar in the same application? Each application needs > only one (in WEB-INF/lib), and the parent classloader needs one (in > common/lib). > > You say that you use "the same log.properties". Do you mean, you configure > the same file names in two different applications? Therefore I guess you get > the same entry from a common library class which is used by two different > apps. > > Or do you mean you see, e.g., an INFO statement in both the > Logger_Debug.txt and the Logger_Info.txt? This would be normal according to > your configuration. > > Your copied config content is not complete. You reference an ERRRO_APPENDER > which is not defined. Are you sure that there is no other logger declaration > in your config file, without the additivity flag, but the same appenders? > This would be the reason for having double log entries. > > Please explain more accurate. > > Heri > > > > > -Ursprüngliche Nachricht- > Von: S.Kannan [mailto:techy_k...@yahoo.co.in] > Gesendet: Mittwoch, 16. September 2009 17:49 > An: log4j-user@logging.apache.org > Betreff: Re: AW: Logging done in the wrong files > > > Infact i tried using > > log4j.rootLogger.additivity=false > > but that has not solved the issue. > I guess that is not the correct solution.. > Trying still.. > > Kannan.S > > > > S.Kannan wrote: > > > > Bender > > > > I tried the first solution. With the same log.properties file i get > > duplicate entries in the log files. > > Is it because there are two log4j.jar files or any other issue > > > > log4j.threshold=ALL > > log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER > > > > log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender > > log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 > > log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB > > log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug.txt > > log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout > > log4j.appender.DEBUG_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > > log4j.appender.DEBUG_APPENDER.Append=false > > log4j.appender.DEBUG_APPENDER.Threshold=DEBUG > > > > log4j.appender.INFO_APPENDER=org.apache.log4j.RollingFileAppender > > log4j.appender.INFO_APPENDER.MaxBackupIndex=50 > > log4j.appender.INFO_APPENDER.MaxFileSize=10MB > > log4j.appender.INFO_APPENDER.file=data/tda/logs/Logger_Info.txt > > log4j.appender.INFO_APPENDER.layout=org.apache.log4j.PatternLayout > > log4j.appender.INFO_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > > log4j.appender.INFO_APPENDER.Append=false > > log4j.appender.INFO_APPENDER.Threshold=INFO > > > > Thanks, > > Kannan.S > > > > -- > View this message in context: > http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25475242.html > Sent from the Log4j - Users mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > > - > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: AW: Logging done in the wrong files
Yogesh Please do not bring another problem into this thread. This is only confusing. Start your own thread with a clear question. BTW: you cannot attach files to this list. You have to copy the content into the mail itself. Heri Von: yogesh kumar [mailto:yog...@gmail.com] Gesendet: Donnerstag, 17. September 2009 09:06 An: Log4J Users List Betreff: Re: AW: Logging done in the wrong files HI , Actually , my problem is my log4j is not logging in a proper path, i.e its not taking the path defined in log4j.properties file.i have attached my log4j.properties file , and we are using custom log4j and we have added in a shared variable of WAS, all logs are getting in a WAS logs path with a short names , and also timestamp attached in the logs are wrong, Regards, Yogesh On Thu, Sep 17, 2009 at 12:16 PM, Bender Heri mailto:hben...@ergonomics.ch>> wrote: Additivity flag has no effect on root logger since the root logger is the uppermost logger within the hierarchy. The flag is only meant for subordinated loggers (e.g. com.my.company. ...). Do you have two log4j.jar in the same application? Each application needs only one (in WEB-INF/lib), and the parent classloader needs one (in common/lib). You say that you use "the same log.properties". Do you mean, you configure the same file names in two different applications? Therefore I guess you get the same entry from a common library class which is used by two different apps. Or do you mean you see, e.g., an INFO statement in both the Logger_Debug.txt and the Logger_Info.txt? This would be normal according to your configuration. Your copied config content is not complete. You reference an ERRRO_APPENDER which is not defined. Are you sure that there is no other logger declaration in your config file, without the additivity flag, but the same appenders? This would be the reason for having double log entries. Please explain more accurate. Heri -Ursprüngliche Nachricht- Von: S.Kannan [mailto:techy_k...@yahoo.co.in<mailto:techy_k...@yahoo.co.in>] Gesendet: Mittwoch, 16. September 2009 17:49 An: log4j-user@logging.apache.org<mailto:log4j-user@logging.apache.org> Betreff: Re: AW: Logging done in the wrong files Infact i tried using log4j.rootLogger.additivity=false but that has not solved the issue. I guess that is not the correct solution.. Trying still.. Kannan.S S.Kannan wrote: > > Bender > > I tried the first solution. With the same log.properties file i get > duplicate entries in the log files. > Is it because there are two log4j.jar files or any other issue > > log4j.threshold=ALL > log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER > > log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 > log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB > log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug.txt > log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.DEBUG_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.DEBUG_APPENDER.Append=false > log4j.appender.DEBUG_APPENDER.Threshold=DEBUG > > log4j.appender.INFO_APPENDER=org.apache.log4j.RollingFileAppender > log4j.appender.INFO_APPENDER.MaxBackupIndex=50 > log4j.appender.INFO_APPENDER.MaxFileSize=10MB > log4j.appender.INFO_APPENDER.file=data/tda/logs/Logger_Info.txt > log4j.appender.INFO_APPENDER.layout=org.apache.log4j.PatternLayout > log4j.appender.INFO_APPENDER.layout.ConversionPattern=%d %-5p - %m%n > log4j.appender.INFO_APPENDER.Append=false > log4j.appender.INFO_APPENDER.Threshold=INFO > > Thanks, > Kannan.S > -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25475242.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org<mailto:log4j-user-unsubscr...@logging.apache.org> For additional commands, e-mail: log4j-user-h...@logging.apache.org<mailto:log4j-user-h...@logging.apache.org> - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org<mailto:log4j-user-unsubscr...@logging.apache.org> For additional commands, e-mail: log4j-user-h...@logging.apache.org<mailto:log4j-user-h...@logging.apache.org>
Re: AW: AW: Logging done in the wrong files
Sorry heri..was in a leave for some time.. here are the answers for your question 1. Do you have two log4j.jar in the same application No for each EAR file i have given only one log4j.jar file and by default jboss comes with a log4j.jar file 2. You say that you use "the same log.properties".. Yes i use the same log.properties file in which the file name is alone different. 3. "Or do you mean you see, e.g., an INFO statement in both the Logger_Debug.txt and the Logger_Info.txt?" This i came to know as you said , is normal. Please ignore the ERROR_APPENDER. Finding a tough time to avoid the duplicate issue. I also think of shifting from properties to xml file configuration which has some more features. One thing which i noticed is when the xml files are used with each log4j.jar file in each EAR file the back up index files are not getting created. But in the properties file for the same usage of log4j.jar file in each EAR file the back up is created. Anything fishy? -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25641480.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: AW: AW: Logging done in the wrong files
Sorry ... One thing which i noticed is when the xml files are used with each log4j.jar file in each EAR file the back up index files are not getting created. But in the properties file for the same usage of log4j.jar file in each EAR file the back up is created. The above observation is wrong. For both the properties and xml file the back up is not created. Please advice. S.Kannan wrote: > > Sorry heri..was in a leave for some time.. > here are the answers for your question > 1. Do you have two log4j.jar in the same application > No for each EAR file i have given only one log4j.jar file and by > default jboss comes with a log4j.jar file > 2. You say that you use "the same log.properties".. > Yes i use the same log.properties file in which the file name is alone > different. > 3. "Or do you mean you see, e.g., an INFO statement in both the > Logger_Debug.txt and the Logger_Info.txt?" > This i came to know as you said , is normal. > > Please ignore the ERROR_APPENDER. > > Finding a tough time to avoid the duplicate issue. > > I also think of shifting from properties to xml file configuration which > has some more features. > One thing which i noticed is when the xml files are used with each > log4j.jar file in each EAR file the back up index files are not getting > created. But in the properties file for the same usage of log4j.jar file > in each EAR file the back up is created. Anything fishy? > > -- View this message in context: http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25641484.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org