RE: [SCL-3] using of system properties in subject of SMTPAppender
Usually a customer is served within one separate thread, isn't it? If yes, you can use the MDC (mapped diagnostic context). You put a value into it: MDC.put(CUSTOMER, SOME NAME) at the begin of the session (probably in a servlet listener) and reference this value with the layout pattern %X{CUSTOMER}. Do not forget to remove the value when session terminates! Heri -Original Message- From: Zbynek Vavros [mailto:zbynek_vav...@cz.ibm.com] Sent: Monday, May 23, 2011 4:18 PM To: log4j-user@logging.apache.org Subject: [SCL-3] using of system properties in subject of SMTPAppender Hi, I have a 1 server app and many clients app on different servers. Obviously I wanted to know from which server the email comes, so I used this: log4j.xml appender name=email class=org.apache.log4j.net.SMTPAppender param name=BufferSize value=512 / param name=SMTPHost value=my_smtp_host / param name=From value=AutoBot / param name=To value=my_em...@someserver.com / param name=Subject value=Agent on [${HOSTNAME}] has encountered error / layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss} [%t] %p %C (%L) %x - %m%n / /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=error / param name=LevelMax value=fatal / /filter /appender and since system property has to be setup before configuring log4j, I use this in my code. Main class //create system property to hold server name System.setProperty(HOSTNAME, InetAddress.getLocalHost ().getCanonicalHostName()); //reconfigure log4j so it picks up HOSTNAME property DOMConfigurator.configure(getClass().getClassLoader().getResource( log4j.xml)); Then Im receiving emails with subject like this: Agent on [127.0.0.1] has encountered error. So far so good. And now I have request to include customer name in subject. I have no problem to include it in stack trace, but since I cannot set customer name the same way as I did with IP (there are multiple customers handled by my app so I cannot just use System.setProperty(CUSTOMER, SOME NAME)). I though of solution to set this property when exception is catched and reconfigure log4j after setting proper customer name into system property. But I think it is politelly said ugly. Can some1 suggest a better way maybe? Thanks, Zbynek Kind Regards / Mit freundlichen Grüßen / Üdvözlettel / S pozdravem: Zbynek VAVROS (Embedded Development image moved to file: pic20342.gif) Delivery Centre 616 00, Brno Central Europe Technicka 21 Brno SITE Czech Republic (Embedded image moved to file: pic17964.gif)Phone: 420-53341- x6283 Mobile: E-mail: zbynek_vav...@cz.ibm.com IBM Global Services Delivery Center Czech Republic, s.r.o. Registered address: Brno, Technicka 2995/21, Zip code: 61600, Company ID: 26244535 Entered in the Commercial Register
RE: is it possible to have different log level for same package
I am not sure about properties configuration. But with xml configuration I would do: - define one logger (your package name, level debug) - assign two appenders to this logger: - appender1: with level range filter error and higher - appender2: without level range filter Heri -Original Message- From: Nitin Kumar Gupta [mailto:nitinkumargu...@gmail.com] Sent: Tuesday, May 17, 2011 5:33 PM To: log4j-user@logging.apache.org Subject: is it possible to have different log level for same package suppose I have a package com.foo.hello , can I define log level and appender such that error logs goes to one file and all other (even including error, if possible) goes to another file. I tried as follows, but last one is always overwriting first one log4j.logger.com.foo.hello=ERROR, FOO_1 log4j.logger.com.foo.hello=DEBUG, FOO_2 and appender as log4j.appender.FOO_1=org.apache.log4j.RollingFileAppender log4j.appender.FOO_1.File=../log/foo_error.log log4j.appender.FOO_2=org.apache.log4j.RollingFileAppender log4j.appender.FOO_2.File=../log/foo_all.log Can someone please help me on that? Thanks a ton Nitin -- View this message in context: http://old.nabble.com/is-it-possible-to-have-different-log-lev el-for-same-package-tp31638492p31638492.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: [SCL-4] Intercepting LoggingEvent
Depends on the implementation of your renderer. The renderer is called only after log4j framework has decided that a logoutput will really occur, means that all checks on log levels of logger and appenders are already executed. Heri -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Friday, November 26, 2010 2:41 PM To: log4j-user@logging.apache.org Subject: Re: [SCL-4] Intercepting LoggingEvent @Heri Do you think this could affect performance ? @Scott It looks like this is not part of 1.2.16 or extras. Git has the code though. -- View this message in context: http://old.nabble.com/Intercepting-LoggingEvent- tp30302884p30308920.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: Help understanding Log4j basics
I've previously searched the manual and I understand the hierarchy of: DEBUG INFO WARN ERROR FATAL However, I'm interested in in learning if there is a way to print ONLY one level rather than the target level and all levels above it. Unless I've missed it, the manual does not explain if this is possible (or how to do it). In order to print a particular level only you can use LevelFilters which you can configure in xml configuration. E.g. appender name=CONSOLE.OUT class=org.apache.log4j.ConsoleAppender param name=target value=System.out/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p [%-7t] %F:%L %x - %m%n/ /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=trace/ param name=LevelMax value=info/ param name=AcceptOnMatch value=false/ /filter /appender - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
RE: [SCL-4] Intercepting LoggingEvent
Write your own Renderer derivation which you can specify in xml configuration (assign to your specific class, see below). The Trick is that you pass a custom object to the log calls (the param need not to be a String, it is formally an object): MySpecificLogInfoHolder infos = new MySpecificLogInfoHolder() myLog.info( infos ); When the log4j framework comes to render (after having checked the levels etc.) it calls your custom renderer where you can render the output string as you like. Heri -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Thursday, November 25, 2010 7:46 AM To: log4j-user@logging.apache.org Subject: [SCL-4] Intercepting LoggingEvent I am trying to intercept the LoggingEvent which is an instance of a custom LoggingEvent created by a library. I have a custom appender and also a filter but neither seems to be a clean way of extracting specific custom information for logging. I think there should be a way to log only what I want from the LoggingEvent by extracting it before the log is written. Is this feasible ? -- View this message in context: http://old.nabble.com/Intercepting-LoggingEvent- tp30302884p30302884.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: Extending Logger
What is the reason you want extend the Logger? Heri -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Thursday, October 21, 2010 1:22 PM To: log4j-user@logging.apache.org Subject: Extending Logger The complete Log4J manual discourages us from extending Logger but we use the recommended pattern then 'repository' and 'getEffectiveLevel()' are inaccessible because they are protected in Category. public void trace(Object message) { if (repository.isDisabled(Level.TRACE_INT)) { return; } if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) { forcedLog(FQCN, Level.TRACE, message, null); } } Can we extend Logger ? -- View this message in context: http://old.nabble.com/Extending-Logger-tp30018462p30018462.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: Extending Logger
If I understand you correctly: You have many instances of your CustomLogger (as many as you want different log files), each wrapping a separate instance of Logger. The name of the file is configured in a file (I assume a pairing of logger names and file names?). My suggestion: Do not extend Logger, but instantiate the Loggers programmatically and supply it with a FileAppender which is also instantiatted programmatically (based on your config file). Heri BTW: The extending of Logger is discouraged not because it would not work (well, some particular features wouldn't work anymore), but because one cannot imagine any reason why this would be necessary. The work of Log4j is done within the Appenders, Filters, Layouts, etc. The Logger class only provides an entry point for log statements in code. -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Tuesday, November 02, 2010 1:26 PM To: log4j-user@logging.apache.org Subject: RE: Extending Logger I wanted to associate the logger file with each Logger instead of the Appender. I have a setFile/getFile in the Logger that I plan to call using my custom Appender so that the log message is written to the file associated with the Logger. Reasons : 1. We have two many appender sections in the XML because there are too many log files. 2. I want to use my custom logger/appender and another xml file - not log4j.xml - to associate a logger with a file. I am trying to parse and read the file name from my custom XML file and set it in my custom logger that log4j's repository has. -- View this message in context: http://old.nabble.com/Extending-Logger-tp30018462p30113301.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: Extending Logger
I am confused. Do you respond to my suggestion? I suggested to set up everything Logger and Appender) programmatically, as it is defined in your own config file. Which performance do you mean? The setup performance or the runtime, when the loggers are used? The latter is independantly of how you set up your logger univers, the former should not concern, or does it? Heri -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Tuesday, November 02, 2010 2:26 PM To: log4j-user@logging.apache.org Subject: RE: Extending Logger So this is what I understand. If I have too many appender sections in the XML then one appender for a logger is created by log4j. Instead of that I can have one appender and a custom logger for each log file. Both could be equivalent as far as performance is concerned. Am I right ? -- View this message in context: http://old.nabble.com/Extending-Logger-tp30018462p30113734.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: Extending Logger
I don't know. You have to try if the log4j.xml can be omitted. Heri -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Tuesday, November 02, 2010 2:39 PM To: log4j-user@logging.apache.org Subject: RE: Extending Logger Yes. I am responding to your suggestion. The setup performance is not very important. The runtime performance though is. If I setup everything programmatically log4j.xml is not at all needed ? -- View this message in context: http://old.nabble.com/Extending-Logger-tp30018462p30113852.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: [SCL-4] Is it possible to configure different log levels for the same appender based on what logger it is coming from?
One possibility I see: Write an own Filter which is attached to the root logger's Apender and filter out the messages which you do not want. Heri -Original Message- From: Adam Creeger [mailto:adamcree...@gmail.com] Sent: Wednesday, October 20, 2010 11:23 PM To: log4j-user@logging.apache.org Subject: [SCL-4] Is it possible to configure different log levels for the same appender based on what logger it is coming from? Hello all, I have a question regarding how I might configure Log4J to support the following scenario: The root logger has an appender (let's call this Appender Z) with a threshold of INFO. There is some important info messages that get logged to that root logger, so we can't set the threshold any higher... Logger A has some verbose info logging that we wish to log to a separate appender (Appender Y). We want Logger A's warn and error messages to appear in the root logger, but not Logger A's info messages. It is totally fine for Logger A's warn and error messages to appear in Appender Y. If I set additivity to false on Logger A, none of its warn or error messages will make it to Appender Z. If I leave additivity as true, all of its info messages will appear in Appender Z, which is not what we want. Is there something I'm missing here? Thanks! Adam - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
RE: [SCL-3] deploying several log files
The loggers, if their names contain dots (like yours es.indra) form a hierarchy based on these dots. If in code you you fetch a named logger (i.e. es.indra.something) there will be a logger instance in the repository but no appenders attached (because it is not configured in the xml file). Log statements issued on this logger climb up the hierarchy. The logger es.indra is found, and its appender served. If there is no additivity attribute (or =true which is the default) the climbing goes on until it reaches the root logger. All Appenders of all Loggers found on this way are served. If a Logger is found which has the additivity flag=false the climbing up the hierarchy stops. So, log statements issued on the logger es.indra.segurcaixa end up in the configured logger es.indra and not reach the root logger, but statements issued to a logger named com.xy would reach the root logger. Heri es.indra.segurcaixa.expedientevirtual.event.cataloger -Original Message- From: Marco Silva [mailto:mlsil...@gmail.com] Sent: Wednesday, April 14, 2010 12:56 PM To: Log4J Users List Subject: Re: [SCL-3] deploying several log files Hi Heri: Reviewing this XML , I saw the root logger has the same appender-ref ref=CATALOGER_FILE_APPENDER . So this should have the same impact? Below I copied the all XML which I reviewing. ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; appender name=CATALOGER_FILE_APPENDER class=org.apache.log4j.RollingFileAppender param name=File value=C:/apps/segurcaixa/expvirtual/workspace/scev-fs/logs/scev-cataloger.log / param name=Append value=true / layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d %-5p - %m%n/ /layout /appender appender name=CONSOLE_APPENDER class=org.apache.log4j.ConsoleAppender param name=Target value=System.Out/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d %-5p - %m%n/ /layout /appender category name=es.indra additivity=false level value=DEBUG/ appender-ref ref=CATALOGER_FILE_APPENDER/ /category category name=es.indra.segurcaixa.expedientevirtual.event.cataloger additivity=false priority value=WARN/ appender-ref ref=CATALOGER_FILE_APPENDER/ /category root level value=WARN / appender-ref ref=CATALOGER_FILE_APPENDER/ /root /log4j:configuration Saludos Marco Silva EAI Consultant On Wed, Apr 14, 2010 at 11:48 AM, Bender Heri hben...@ergonomics.ch wrote: Add the attribute additivity=false to your specialized loggers in order to not have the log output in the root logger: category name=package1 additivity=false priority value=WARN/ appender-ref ref=CATALOGER_FILE_APPENDER/ /category Heri -Original Message- From: Marco Silva [mailto:mlsil...@gmail.com] Sent: Wednesday, April 14, 2010 11:15 AM To: log4j-user@logging.apache.org Subject: [SCL-3] deploying several log files Hi All, I´ll try to describe my problem, describing my context: I'm maintaining an app which uses Log4j to generate several file logs (one log per module event of data loaded on the DB), each file log is filled by events which start in filenet by several apps deployed in Websphere (WAR) , each module has his own XML . So my problem is only one file log is filled for all modules, initially I saw each XML configuration file doesn´t have the package identified, so I´ve changed this putting package1, package2, package3. But now I see and expression ROOT as is described below, I don´t know if this should be keep it in each XML configuration file? !-- category name=ALL-- category name=package1 priority value=WARN/ appender-ref ref=CATALOGER_FILE_APPENDER/ /category root levvalue=WARN / appender-ref ref=CATALOGER_FILE_APPENDER/ /root -- Regards Marco Silva EAI Consultant - 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: [SCL-2] Re: Multiple log files, multiple logger names and the same appender
If I understand you correctly, you want to have several loggers all using the same appender? Use the hierarchical approach of the logger repository by prefixing your logger names: logger name=loggerFamily1.Test1 level value=info/ /logger logger name=loggerFamily1.Test2 level value=warn/ /logger logger name=loggerFamily1 additivity=false appender-ref ref=MultiplexingAppender1 / /logger more loggers for family2 logger name=loggerFamily2 additivity=false appender-ref ref=MultiplexingAppender2 / /logger Like this all loggers of loggerFamily1 write to the appender MultiplexingAppender1, but on different log-levels, and all loggers of loggerFamily2 write to appender MultiplexingAppender2. Heri -Original Message- From: Mohan.Radhakrishnan [mailto:moh...@fss.co.in] Sent: Thursday, April 08, 2010 9:55 AM To: log4j-user@logging.apache.org Subject: [SCL-2] Re: Multiple log files, multiple logger names and the same appender Hopefully more explanation can attract some ideas here. I am using XML configuration and a custom appender. So I have one section in the XML corresponding to one logger name and one log file. So for each different logger name, log file and the same custom appender I need to add one more section in log4j.xml Is there a way to parameterize the logger section and the log file so that one section can substitute for multiple sections ? The same appender is used for all sections. -- View this message in context: http://old.nabble.com/Multiple-log-files%2C-multiple-logger-names-and-the-same-appender-tp28024737p28175329.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
AW: Path exclusion for logs
Probably the parent class does not instantiate his logger statically but like this: Logger logger = Logger.getLogger( this.getClass().getName() ); and therefore it retrieves a logger with the name of your descendant (name starting with your namespace). If it would instantiate it statically: static Logger logger = Logger.getLogger( org.apache. ..ApacheParent.class ); then the name of the logger would start with org.apache. .. and would be excluded if you have a corresponding configuration. Just a guess. If this is not the case, you should submit your config file for further analyzis. Heri -Ursprüngliche Nachricht- Von: Angeli106 [mailto:angeli...@gmail.com] Gesendet: Donnerstag, 18. März 2010 14:50 An: log4j-user@logging.apache.org Betreff: Path exclusion for logs Hi, I have a java class inheriting from an apache class file. The apache class file is packaged in org.apache... and such i do not see the logs for it, which is great. However, my own class is within my namespace (which i'm logging) and as such it now writes the logs of the parent class.. my question is, can i exclude certain paths from the log? (such as the path for the class that i've inherited) -- View this message in context: http://old.nabble.com/Path-exclusion-for-logs-tp27945800p27945800.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
AW: AW: Path exclusion for logs
Either: you patch the apache class yourself or submit a bug to its developers (or both) Or: you implement a workaround: - exclude the path of your own class (like it is seen by the apache getClass(): logger name=my.company.HttpClient additivity=false level value=off/ /logger - instantiate your own logger with an artificial addendum in the name: private final static Log log = LogFactory.getLog( my.company.reallyMy.HttpClient ); and configure it like: logger name=my.company.reallyMy.HttpClient level value=debug/ /logger remember: the name of the logger is just a name. Using the package/Classname is just a convention and not a must. Or - of course - both. Heri -Ursprüngliche Nachricht- Von: Angeli106 [mailto:angeli...@gmail.com] Gesendet: Donnerstag, 18. März 2010 15:51 An: log4j-user@logging.apache.org Betreff: Re: AW: Path exclusion for logs Turns out u were right, the parent class(AbstractHttpClient) instantiates the log like this: private final Log log = LogFactory.getLog(getClass()); Also turns out that this is a commons.logging logger and not a log4j as i thought Also it looks like it's private so i can't override it, any ideas? Bender Heri wrote: Probably the parent class does not instantiate his logger statically but like this: Logger logger = Logger.getLogger( this.getClass().getName() ); and therefore it retrieves a logger with the name of your descendant (name starting with your namespace). If it would instantiate it statically: static Logger logger = Logger.getLogger( org.apache. ..ApacheParent.class ); then the name of the logger would start with org.apache. .. and would be excluded if you have a corresponding configuration. Just a guess. If this is not the case, you should submit your config file for further analyzis. Heri -Ursprüngliche Nachricht- Von: Angeli106 [mailto:angeli...@gmail.com] Gesendet: Donnerstag, 18. März 2010 14:50 An: log4j-user@logging.apache.org Betreff: Path exclusion for logs Hi, I have a java class inheriting from an apache class file. The apache class file is packaged in org.apache... and such i do not see the logs for it, which is great. However, my own class is within my namespace (which i'm logging) and as such it now writes the logs of the parent class.. my question is, can i exclude certain paths from the log? (such as the path for the class that i've inherited) -- View this message in context: http://old.nabble.com/Path-exclusion-for-logs-tp27945800p27945800.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 -- View this message in context: http://old.nabble.com/Path-exclusion-for-logs-tp27945800p27946728.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
AW: Problems with inheritance of com.foo... loggers
There is one point more: You do not define a root logger in your config which has some benefits The root is the parent for all loggers which are not explicitely defined (e.g. also for third party libraries like org.apache). Typically you set the root logger level to WARN. And for the package/classes which you want to examine deeper you define a extra logger with desired lower level. If you want to have a lot of logger configurations which differ only in level setting but have all the same appender, then you define the appender only once in the root logger. Only if you explicitely want to have one distinct logger to log to another appender you define it in the respective logger definition and set the attribute additivity=false (default is true). Heri -Ursprüngliche Nachricht- Von: Jens Gruentjes [mailto:jens.gruent...@ebira.de] Gesendet: Donnerstag, 4. Februar 2010 15:36 An: log4j-user@logging.apache.org Betreff: Re: Problems with inheritance of com.foo... loggers Hi Douglas, thanks for your answer which helped me save a lot of time. Your explanation is evident but I did not realize that for myself. -- Kind regards Jens Zitat von Douglas E Wegscheid douglas_e_wegsch...@whirlpool.com: de.wota.segmentation.Bar will inherit from de.wota.segmentation, de.wota, and de but not de.wota.MyApp. Change your configuration to set up logging for de.wota instead of de.wota.MyApp. Douglas E Wegscheid Lead Technical Analyst, Whirlpool Corporation (269)-923-5278 A wrong note played hesitatingly is a wrong note. A wrong note played with conviction is interpretation. Jens Gruentjes jens.gruent...@ebira.de wrote on 02/04/2010 02:57:10 AM: Hello to all readers, I am new to log4j and I encounter several problems which are maybe caused by my limited understanding fo log4j. I have a simple setup with two classes (de.wota.MyApp and de.wota.segmentation.Bar) and an xml configuration file for log4j. I thought that the logger defined in Bar.java inherits its level and most of all its appender(s) from the logger defined in MyApp.java. But despite reading the manuals and the list archives I always get the following error when I execute MyApp: j...@jensen ~/Java/wota_rw $ java de.wota.MyApp log4j: reset attribute= false. log4j: Threshold =null. log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [de.wota.MyApp] additivity to [true]. log4j: Level value for de.wota.MyApp is [DEBUG]. log4j: de.wota.MyApp level set to DEBUG log4j: Class name: [org.apache.log4j.ConsoleAppender] log4j: Setting property [target] to [System.out]. log4j: Setting property [threshold] to [INFO]. log4j: Parsing layout of class: org.apache.log4j.PatternLayout log4j: Setting property [conversionPattern] to [%8r %p %c %x - %m%n]. log4j: Adding appender named [console] to category [de.wota.MyApp]. 0 INFO de.wota.MyApp - Entering application. log4j:WARN No appenders could be found for logger (de.wota.segmentation.Bar). log4j:WARN Please initialize the log4j system properly. Parent is root 1 INFO de.wota.MyApp - Exiting application. j...@jensen ~/Java/wota_rw $ What I expected to see was the output from Bar.java which is missing here. I wanted to know who is the parent of the logger in Bar.java is and it turned out to be root. I thought that this should be the logger from MyApp.java. Can someone tell me what I misunderstand? I am a little confused. The code follows below. Thanks for your explanations and your help! This is MyApp.java: package de.wota; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; import de.wota.segmentation.Bar; public class MyApp { // Define a static logger variable so that it references the // Logger instance named MyApp. static Logger logger = Logger.getLogger(MyApp.class); public static void main(String[] args) { // Set up an xml configuration that logs on the console. DOMConfigurator.configureAndWatch(config_log.xml); logger.info(Entering application.); Bar bar = new Bar(); bar.doIt(); logger.info(Exiting application.); } } This is Bar.java: package de.wota.segmentation; import org.apache.log4j.Logger; public class Bar { static Logger logger = Logger.getLogger(Bar.class); public void doIt() { logger.debug(Did it again!); System.out.println(Parent is +logger.getParent().getName()); } } And finally config_log.xml ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration debug=true xmlns:log4j=http://jakarta.apache.org/log4j/; appender name=console class=org.apache.log4j.ConsoleAppender param name=Target value=System.out/ param name=threshold value=info / layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%8r %p %c %x - %m%n/
AW: [SCL-4] funny behaviour using filters
I cannot see how you configure the LevelRangeFilter. See my example for separating console.out and console.err: appender name=CONSOLE.ERR class=org.apache.log4j.ConsoleAppender param name=target value=System.err/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p [%-7t] %F:%L %x - %m%n/ /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=warn/ param name=LevelMax value=fatal/ param name=AcceptOnMatch value=false/ /filter /appender appender name=CONSOLE.OUT class=org.apache.log4j.ConsoleAppender param name=target value=System.out/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p [%-7t] %F:%L %x - %m%n/ /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=trace/ param name=LevelMax value=info/ param name=AcceptOnMatch value=false/ /filter /appender Heri -Ursprüngliche Nachricht- Von: takidoso [mailto:malte.kem...@de.equens.com] Gesendet: Dienstag, 17. November 2009 17:55 An: log4j-user@logging.apache.org Betreff: [SCL-4] funny behaviour using filters Hi to all, I am not sure, if that is a bug or a misconcetion of my own. I have following log4j.xml : -- ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; appender name=rootApp class=org.apache.log4j.DailyRollingFileAppender layout class=org.apache.log4j.PatternLayout /layout /appender appender name=gfcApp class=org.apache.log4j.DailyRollingFileAppender layout class=org.apache.log4j.PatternLayout /layout /appender appender name=fdAppErr class=org.apache.log4j.DailyRollingFileAppender layout class=org.apache.log4j.PatternLayout /layout filter class=org.apache.log4j.varia.LevelRangeFilter /filter /appender appender name=fdAppLog class=org.apache.log4j.DailyRollingFileAppender layout class=org.apache.log4j.PatternLayout /layout filter class=org.apache.log4j.varia.LevelRangeFilter /filter /appender appender name=fdAppTrace class=org.apache.log4j.DailyRollingFileAppender layout class=org.apache.log4j.PatternLayout /layout /appender category name=de.equens.filedemon additivity=false priority value=INFO /priority appender-ref ref=fdAppErr / appender-ref ref=fdAppLog / /category category name=de.equens.fileconverter additivity=false priority value=WARN /priority appender-ref ref=gfcApp / /category root priority value=off/ /root /log4j:configuration --- I notice, that I cannot find any warning even though I put defenitely one out. I intend with this configuration that a warning would be found in filedemon.log as well in filedemon.error, since I have put the logger (or category) to Level Info. I cannot find the warning anywere, but errors and infos are where I expect them. What am i doing wrong? Thanks for hints in advance Takidoso -- View this message in context: http://old.nabble.com/funny-behaviour-using-filters-tp26393423p26393423.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
AW: Log4j.xml setting for Hibernate not working
Are you sure that your log configuration file is picked up? Maybe there is annother config file on the class path which is used before yours is found. I have no problems on Tomcat with special hibernate loggers. Heri -Ursprüngliche Nachricht- Von: John2000 [mailto:johnk...@gmail.com] Gesendet: Montag, 16. November 2009 12:57 An: log4j-user@logging.apache.org Betreff: Log4j.xml setting for Hibernate not working We are using log4j.xml for logging. Everything is working fine except hibernet logging. All logs files are crated but for hibernate only log file is created and it remains empty. My log4j.xml settings are appender name=HIBERNATELOG class=org.apache.log4j.RollingFileAppender layout class=com.common.logging.client.CommonLoggingLayout /layout /appender logger name=org.hibernate additivity=false level value=DEBUG/ appender-ref ref=HIBERNATELOG/ /logger here ../log/hibernate.log file is created in tomcat but nothing after that. I can see logs on console and in cataline.out file. Please help. Thanks in advance. -- View this message in context: http://old.nabble.com/Log4j.xml-setting-for-Hibernate-not-working-tp26370675p26370675.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
AW: AW: Log4j.xml setting for Hibernate not working
Hibernate uses the commons-logging framework. Your list of jars does not include the commons-logging.jar. I guess that hibernate when loaded the first time finds the commons-logging of the tomcat root libraries and initializes there, where your special logger is not found. Include a commons-logging.jar into your lib and there you go Heri -Ursprüngliche Nachricht- Von: John2000 [mailto:johnk...@gmail.com] Gesendet: Montag, 16. November 2009 15:30 An: log4j-user@logging.apache.org Betreff: Re: AW: Log4j.xml setting for Hibernate not working Yes I have only log4j.xml. No other file in class path:( And my file is being taken bcaz it creates hibernate.log file but it remains empty. I also tried to removing log settings in hibernate.cfg.xml but in no luck. I have these jars in WEB-INF\lib 09/02/2009 08:10 PM62,394 activation.jar 08/31/2009 11:27 AM 2,631,190 activemq-all-5.2.0.jar 09/10/2009 11:05 AM 435,564 antlr-2.7.5.jar 09/02/2009 08:11 PM26,361 asm-1.5.3.jar 10/21/2009 12:12 PM29,002 avaya-logging-client-1.0.jar 09/02/2009 08:11 PM 605,581 c3p0-0.9.1-pre11.jar 10/05/2009 10:45 AM 322,362 cglib-nodep-2.2.jar 09/02/2009 08:11 PM 175,426 commons-collections-2.1.1.jar 07/19/2008 03:51 AM 214,796 commons-httpclient.jar 09/02/2009 08:10 PM87,077 commons-pool-1.4.jar 09/02/2009 08:11 PM 313,898 dom4j-1.6.1.jar 09/02/2009 08:11 PM 236,115 ehcache-1.3.0.jar 09/10/2009 11:02 AM 410,878 exchange.jar 09/02/2009 08:10 PM 287,960 FastInfoset.jar 09/02/2009 08:11 PM 1,971,632 hibernate3.jar 09/02/2009 08:10 PM79,619 http.jar 08/06/2009 10:14 PM 289,954 httpclient-4.0.jar 09/02/2009 08:10 PM89,193 jaxb-api.jar 09/02/2009 08:11 PM 844,121 jaxb-impl.jar 09/02/2009 08:11 PM 3,090,959 jaxb-xjc.jar 09/02/2009 08:11 PM35,914 jaxws-api.jar 09/02/2009 08:11 PM 1,266,110 jaxws-rt.jar 09/02/2009 08:11 PM 502,816 jaxws-tools.jar 08/31/2009 11:27 AM25,998 jms.jar 09/02/2009 08:11 PM23,246 jsr173_api.jar 09/02/2009 08:11 PM 7,956 jsr181-api.jar 09/02/2009 08:11 PM 5,948 jsr250-api.jar 08/05/2009 01:08 PM 391,834 log4j-1.2.15.jar 09/02/2009 08:11 PM 371,264 mail.jar 11/02/2009 11:32 AM 320,677 MessageAPIs-20091102.jar 10/29/2009 04:50 PM44,809 messageEventSystemStub.jar 09/02/2009 08:11 PM38,240 mimepull.jar 09/24/2009 11:50 AM 723,660 mysql-connector-java-5.1.8-bin.jar 09/02/2009 08:11 PM66,786 resolver.jar 09/02/2009 08:11 PM18,623 saaj-api.jar 09/02/2009 08:11 PM 273,722 saaj-impl.jar 10/26/2009 01:55 PM85,287 servlet-api.jar 09/02/2009 08:11 PM 330,222 sjsxp.jar 09/02/2009 08:11 PM10,958 stax-ex.jar 09/02/2009 08:11 PM57,250 streambuffer.jar 40 File(s) 16,805,402 bytes 2 Dir(s) 52,573,892,608 bytes free --John Bender Heri wrote: Are you sure that your log configuration file is picked up? Maybe there is annother config file on the class path which is used before yours is found. I have no problems on Tomcat with special hibernate loggers. Heri -Ursprüngliche Nachricht- Von: John2000 [mailto:johnk...@gmail.com] Gesendet: Montag, 16. November 2009 12:57 An: log4j-user@logging.apache.org Betreff: Log4j.xml setting for Hibernate not working We are using log4j.xml for logging. Everything is working fine except hibernet logging. All logs files are crated but for hibernate only log file is created and it remains empty. My log4j.xml settings are appender name=HIBERNATELOG class=org.apache.log4j.RollingFileAppender layout class=com.common.logging.client.CommonLoggingLayout /layout /appender logger name=org.hibernate additivity=false level value=DEBUG/ appender-ref ref=HIBERNATELOG/ /logger here ../log/hibernate.log file is created in tomcat but nothing after that. I can see logs on console and in cataline.out file. Please help. Thanks in advance. -- View this message in context: http://old.nabble.com/Log4j.xml-setting-for-Hibernate-not-working-tp26 370675p26370675.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
AW: Using two SMTPAppenders
First what I notice is the same int value of your custom levels (both have 6). But: Why that complicated? Why not only define two separate loggers by name, a SuccessLogger and a FailLogger? The places where one of these loggers are called know about the success or the failure (your solution has to set the correct level, my solution only fetch the correct logger) Heri -Ursprüngliche Nachricht- Von: S.Kannan [mailto:techy_k...@yahoo.co.in] Gesendet: Freitag, 6. November 2009 09:14 An: log4j-user@logging.apache.org Betreff: Using two SMTPAppenders Hi All There seems to be some trouble configuring two Appenders for sending mails. In our case we have to define two custom levels and send mails when these two levels are used for logging. The following is the custom level class(Since we want both the levels to be equal something more than FATAL) public class CustomLevel extends Level { // Defining SUCCESS constants public static final int SUCCESS_INT = 6; public static final String SUCCESS_STRING = SUCCESS; public static final Level SUCCESS = new CustomLevel (SUCCESS_INT, SUCCESS_STRING, 0); // Defining FAILURE constants public static final int FAILURE_INT = 6; public static final String FAILURE_STRING = FAILURE; public static final Level FAILURE = new CustomLevel (FAILURE_INT, FAILURE_STRING, 0); public CustomLevel (int intValue, String levelName, int sysLogEquivalent) { super(intValue, levelName, sysLogEquivalent); } } As the default level for mail triggering is ERROR i modified the log.properties file like the below one log4j.rootLogger=ALL,DEBUG_APPENDER,,SUCCESS_APPENDER,FAILURE_APPENDER log4j.appender.SUCCESS_APPENDER=org.abc.util.MyOwnSmtpAppender log4j.appender.SUCCESS_APPENDER.BufferSize=1 log4j.appender.success_appender.from=nore...@mycomp.int log4j.appender.success_appender.to=kanna...@mycomp.int log4j.appender.success_appender.cc=kanna...@mycomp.int log4j.appender.SUCCESS_APPENDER.Subject=Tour log4j.appender.SUCCESS_APPENDER.evaluatorClass=org.abc.util.AbcEventEvaluator log4j.appender.SUCCESS_APPENDER.Threshold=SUCCESS#org.abc.util.CustomLevel log4j.appender.SUCCESS_APPENDER.SMTPHost=localhost log4j.appender.SUCCESS_APPENDER.layout=org.apache.log4j.PatternLayout log4j.appender.SUCCESS_APPENDER.layout.ConversionPattern=%d [%t] %-5p %c - %m%n log4j.appender.FAILURE_APPENDER=org.abc.util.MyOwnSmtpAppender log4j.appender.FAILURE_APPENDER.BufferSize=1 log4j.appender.failure_appender.from=nore...@mycomp.int log4j.appender.failure_appender.to=kan...@mycomp.int log4j.appender.failure_appender.cc=skan...@mycomp.int log4j.appender.FAILURE_APPENDER.evaluatorClass=org.abc.util.AbcEventEvaluator log4j.appender.FAILURE_APPENDER.Threshold=FAILURE#org.abc.util.CustomLevel log4j.appender.FAILURE_APPENDER.SMTPHost=localhost log4j.appender.FAILURE_APPENDER.Subject=Log4J Mail Failure log4j.appender.FAILURE_APPENDER.layout=org.apache.log4j.PatternLayout log4j.appender.FAILURE_APPENDER.layout.ConversionPattern=%d [%t] %-5p %c - %m%n The AbcEventEvaluatorclass is as follows public class AbcEventEvaluatorimplements TriggeringEventEvaluator { @Override public boolean isTriggeringEvent(LoggingEvent event) { System.out.println(Trigerring event Level:+event.getLevel()); boolean isTriggered = false; if (event.getLevel().equals(CustomLevel.SUCCESS)) { isTriggered = true; System.out.println(isTriggeringEvent SUCCESS ); }else if (event.getLevel().equals(CustomLevel.FAILURE)){ isTriggered = true; System.out.println(isTriggeringEvent FAILURE ); } return isTriggered; } } The customized appender is public class MyOwnSmtpAppender extends SMTPAppender{ @Override public void setEvaluatorClass(String arg0) { // TODO Auto-generated method stub System.out.println(Setting the evaluator class:+arg0); super.setEvaluatorClass(arg0); } @Override public String getEvaluatorClass() { // TODO Auto-generated method stub return super.getEvaluatorClass(); } @Override public void setThreshold(Priority threshold) { // TODO Auto-generated method stub System.out.println(Setting the threshold+threshold.getSyslogEquivalent()); super.setThreshold(threshold); } @Override public Priority getThreshold() { // TODO Auto-generated method stub return super.getThreshold(); } } Now the problem is that i get two mails both from the
AW: Is DailyRollingFileAppender efficient or safe to use if log file is huge?
logfiles up to 200 MB didnt throw any problems (on windows XP and winserver2003 with NTFS). Heri -Ursprüngliche Nachricht- Von: shaoxianyang [mailto:ysxsu...@hotmail.com] Gesendet: Montag, 2. November 2009 21:47 An: log4j-user@logging.apache.org Betreff: Is DailyRollingFileAppender efficient or safe to use if log file is huge? Hi, I am using log4j 1.2.15. I am pondering between DailyRollingFileAppender and RollingFileAppender. For RollingFileAppender, I can enforce file size limit and MaxBackupIndex. But for DailyRollingFileAppender, i can not limit either. Aside from being difficult to plan disk space usage in advance, does DailyRollingFileAppender cause inefficiency if the log file become huge? In theory, the log4j just keeps a fiel descriptor and append to the end. It should not matter that much if the log file is big or small. Did I miss anything? Any feedback or recommendation is appreciated. Thanks. Shaoxian Yang -- View this message in context: http://old.nabble.com/Is-DailyRollingFileAppender-efficient-or-safe-to-use-if-log-file-is-huge--tp26157824p26157824.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
AW: FileAppender is not assignable to Appender
My guess: there are two log4j.jar, probably of different versions: one in the parent classlaoder and one in the child classloader. Therefore java regards these two as different classes. Heri -Ursprüngliche Nachricht- Von: chrisgage [mailto:chrisg...@bellsouth.net] Gesendet: Mittwoch, 28. Oktober 2009 14:53 An: log4j-user@logging.apache.org Betreff: FileAppender is not assignable to Appender With an application we have been running in production, we recently added some jar files from another department's application in order to have the wto apps communicate. Since then we have been getting the following error in the log at application startup. It does not appear to cause log4j to stop working, it's just a worrying thing to see in the log. I am using log4j as a black box at the simplest possible level, so this message is completely incomprehensible to me, and it gives no stack trace or other indication where the problem is occurring. log4j:ERROR A org.apache.log4j.FileAppender object is not assignable to a org.apache.log4j.Appender variable. log4j:ERROR The class org.apache.log4j.Appender was loaded by log4j:ERROR [ com.ibm.ws.classloader.compoundclassloa...@d940d94 Local ClassPath: ... Delegation Mode: PARENT_FIRST] whereas object of type log4j:ERROR org.apache.log4j.FileAppender was loaded by [ com.ibm.ws.classloader.compoundclassloa...@8060806 Local ClassPath: ... Delegation Mode: PARENT_FIRST]. log4j:ERROR Could not instantiate appender named SPRINGLOG. Actually this set of messages occurs twice, once for FileAppender and the repeated almost identically for ConsoleAppender. -- View this message in context: http://www.nabble.com/FileAppender-is-not-assignable-to-Appender-tp26095007p26095007.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
AW: convert org.apache.log4j.Logger to org.apache.commons.logging.Log
You cannot cast it. But if you instantiate the commons Logger with the same name as your log4j logger your log statements will end up in the same logger instance (log4j Logger). Commons logging is only a wrapper, and instantiates log4j if it finds a log4j.jar in the classpath (and not configured otherwise). If you do not need special functionality of log4j interface which is not covered by commons-logging, I recommend that you replace the existing logger in your calling class by an instance of commons-logging Logger and use this instance to pass to the library and use for logging in the calling class. Heri -Ursprüngliche Nachricht- Von: rouble [mailto:rou...@gmail.com] Gesendet: Mittwoch, 28. Oktober 2009 14:59 An: log4j-user@logging.apache.org Betreff: convert org.apache.log4j.Logger to org.apache.commons.logging.Log Hi All, The class I am working in has org.apache.log4j.Logger object, and I am working with a third party library class that requires me to pass in a org.apache.commons.logging.Log object to create an instance of the factory object of that third party library. The third party library uses the passed in Log object to send logs directly to the same logger/logfile as the calling class. Note, that I cannot change the third party library, but I do have access to org.apache.commons.logging.Log in my own code. I was wondering if it is possible to cast or convert a org.apache.log4j.Logger to a org.apache.commons.logging.Log, or if I need to create a new Log object and pass that in to the third party library? tia, rouble - 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: Logging without logging to the root logger
logger name=db_report additivity=false level value=info / appender-ref ref=reportFileAppender/ /logger -Ursprüngliche Nachricht- Von: Ofer Kalisky [mailto:kali...@hotmail.com] Gesendet: Mittwoch, 21. Oktober 2009 20:15 An: log4j-user@logging.apache.org Betreff: Logging without logging to the root logger Hi, I have the following config: log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; appender name=reportFileAppender class=org.apache.log4j.RollingFileAppender !-- Keep one backup file -- layout class=org.apache.log4j.PatternLayout /layout /appender appender name=stdoutAppender class=org.apache.log4j.ConsoleAppender layout class=org.apache.log4j.PatternLayout /layout /appender logger name=db_report level value=info / appender-ref ref=reportFileAppender/ /logger logger name=com.mycompany level value=info / /logger root priority value=warn/ appender-ref ref=stdoutAppender/ /root /log4j:configuration In the source I do: private static Logger reportLogger = Logger.getLogger(db_report); and in other classes I do: private static Logger anyClassLogger = Logger.getLogger(com.mycompany.MyClass.class); I would like things logged to the db_report not to be logged in the stdoutAppender, but I can't get them out of there, since the root logger has it and it seems it catches all... how can I log things to the report.log file without it being outputted to the stdout as well? thanks -- View this message in context: http://www.nabble.com/Logging-without-logging-to-the-root-logger-tp25997550p25997550.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
AW: Log session session information (Web)
Of course. MDC content is kept on a per thread basis. Since each session is handled in its own thread, you can put a value into the MDC somewhere at the entry point of a session (and remove it again when session is finished). The formatter of log4j (at least the PatternLayout) can retrieve this value by %X{sessionID} where sessionID is the name of the variable you have putted to MDC. Heri -Ursprüngliche Nachricht- Von: Renan Vinícius Mozone [mailto:renan.moz...@gmail.com] Gesendet: Mittwoch, 30. September 2009 21:08 An: log4j-user@logging.apache.org Betreff: Re: Log session session information (Web) Dear Matt Brown, My JSP application also uses some Java classes. Your solution is suitable for use inside those Java classes? On Wed, Sep 30, 2009 at 15:40, Matt Brown matt.br...@citrixonline.comwrote: I've implemented this before by writing a javax.servlet.Filter to add the SessionID to the MDC of every request. -Original Message- From: Renan Vinícius Mozone [mailto:renan.moz...@gmail.com] Sent: Wednesday, September 30, 2009 2:13 PM To: log4j-user@logging.apache.org Subject: Log session session information (Web) I'm planning to use log4j on a JSP based application. However, every log entry must have a session identification. This session identification is in a session variable. How can I configure the formatter to achieve this? The log entry must be something like this: [TIMESTAMP] [THREAD] [LOG LEVEL] [SESSION ID] [MESSAGE] Thanks in advance. - 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: Configuring log4j with XML
First: For simple configuration needs (in fact for most configuration needs) you do not need to call a configurator explicitely. Just put your config file in the classpath, and log4j finds it for you and autoconfigures itself the first time the LogManager is loaded (e.g. on a static Logger.getLogger()). Log4j looks first for a file log4j.xml, and if not found, for log4j.properties. That's all. (you can overwrite the name of the file by the commandline argument or by system property). Second: You ran into some subtle problems which misleaded you to wrong assumptions. - If for some reasons you must load the configuration programmatically: a XML configuration should be loaded by the DOMConfigurator, a properties file by the PropertiesConfigurator. I suppose in your second experiment the (default) configurator finds the default.xml (given by commandline param), but the PropertyConfigurator cannot load the second xml file (as in all further experiments). - the double output in your third experiment was due you have then two loggers in the hierarchy (both from the default.xml). In code you are calling the logger Test which outputs to its appender, then climbing up to the root logger which outputs the same log message to its appender again (which happens to be the same one). To avoid this, you should declare your Test-Logger with additivity set to false (default true): logger name=Test additivity=false level value=info/ appender-ref ref=stdout / /logger Third: Multiple calls to XXXConfigurator.configure append new configuration items to the already loaded ones unless calling LogManager.resetConfiguration(). When you did this, the first configuration from the default.xml was purged and the second one did not succeed (see above). That's the reason for the last WARN messages. Heri -Ursprüngliche Nachricht- Von: pagod [mailto:dvergn...@yahoo.com] Gesendet: Dienstag, 29. September 2009 18:56 An: log4j-user@logging.apache.org Betreff: Configuring log4j with XML Hi everyone, I seem to have a solid understanding problem with the way log4j loads its configuration, perhaps someone can take a few minutes to explain it to me? I only started a few hours ago, but I'm already startled... :-| Basically, what I want to do is create a simple logger and configure it using an XML file. So my questions are: - does log4j have to load a default configuration file (log4j.xml or whatever I set log4j.configuration to) even if I call the PropertyConfigurator.configure( String filename ) function?? - This wouldn't be such a problem if I understood clearly how the default configuration file interacts with another configuration file I might be trying to load: are the loggers/appenders simply added to the default configuration, or are there any risks when overwriting parts of it? A concrete example: Here's the Java code I'm testing with: import org.apache.log4j.*; public class Test { static Logger __logger; public static void main( String args[] ) throws Exception { // 1 //PropertyConfigurator.configure( ~/log4j_config.xml ); // 2 BasicConfigurator.configure(); __logger = Logger.getLogger( Test.class ); __logger.info( bonjour ); } } Pretty basic. Now I have the following file which is used as the default configuration by specifying -Dlog4j.configuration=log4j_default.xml on the command line when starting java: ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration PUBLIC -//Apache//log4j LOG4J 1.0//EN http://logging.apache.org/log4j/docs/api/org/apache/log4j/xml/log4j.dtd; log4j:configuration appender name=stdout class=org.apache.log4j.ConsoleAppender layout class=org.apache.log4j.PatternLayout /layout /appender root level value=fatal / appender-ref ref=stdout / /root /log4j:configuration Again pretty easy, and when I execute the program I get the expected output (i.e. nothing). Now suppose I have a second file called log4j_config.xml, which is the same as log4j_default.xml, except that it has an additional entry: logger name=Test level value=info/ appender-ref ref=stdout / /logger After uncommenting the line after // 1 in my code and commenting out the one after // 2 (i.e., as I understand it, switching from default configuration to named configuration), I find that the normal output hasn't changed a single bit, although I'd have expected a message bonjour to be dumped to the console (appender stdout is registered for logger Test with level output, which matches the code, doesn't it?). However, the debug output (enabled with -Dlog4j.debug=1) has changed, below is the output after the first call (default config) and, in bold, the two lines added after the second call (file
Appender-ref within appender tag
Hi all The appender tag of xml configuration allows formally to be like that: appender name=STANDARD_APPENDERS class= appender-ref ref=CONSOLE.ERR/ appender-ref ref=CONSOLE.OUT/ appender-ref ref=FILE/ /appender According to DTD: !ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*) !ATTLIST appender name ID #REQUIRED class CDATA #REQUIRED But: how to use this feature? I would like to use one ref to this STANDARD_APPENDERS in my logger definitions, since I have a lot of finetuned logger definitions. But my development environment (eclipse) likes the Console-Appender, whereas the server does not like it. If I can use such a sampler appender I would have to change the included appenders only at one location. Problem is: the class-Attribute of appender element is mandatory. But what to write therein? Left blank (like shown above) leads to a ClassNotFountException. Omitting the attribute says log4j:WARN Attribute class is required and must be specified for element type appender. Followed by a ClassNotFountException again. The log4j manual has no hints about this feature. Any ideas? Heri - 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
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 hben...@ergonomics.chmailto: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.inmailto:techy_k...@yahoo.co.in] Gesendet: Mittwoch, 16. September 2009 17:49 An: log4j-user@logging.apache.orgmailto: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.orgmailto:log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.orgmailto:log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.orgmailto:log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.orgmailto:log4j-user-h...@logging.apache.org
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 !-- A flag indicating if ear deployments should have their own scoped class loader to isolate their classes from other deployments. -- attribute name=Isolatedtrue/attribute 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
AW: Events appear incorrect inside the wrong file
Maybe the PatternLayout is not threadsafe? Try to instantiate separate instances of PatternLayout for each Logger, or synchronize on the sole instance of PatternLayout. Heri PS: It is not quite clear who calls your log method the log-Event, and how looks the other log method which writes to the traceLogger? BTW: Why don't you do the configuring through config file? There is nothing special in your configuration which cannot be done by config file! -Ursprüngliche Nachricht- Von: Markus Michel [mailto:nemocadn...@googlemail.com] Gesendet: Freitag, 28. August 2009 13:58 An: log4j-user@logging.apache.org Betreff: Events appear incorrect inside the wrong file Hi there! To be able to log and trace some events I've added a LoggingHandler class to my java project. Inside this class I'm using two different log4j logger instances - one for logging an event and one for tracing an event into different files. The initialization block of the class looks like this: public void initialize() { System.out.print(starting logging server ...); // create logger instances logLogger = Logger.getLogger(log); traceLogger = Logger.getLogger(trace); // create pattern layout String conversionPattern = %c{2} %d{ABSOLUTE} %r %p %m%n; try { patternLayout = new PatternLayout(); patternLayout.setConversionPattern(conversionPattern); } catch (Exception e) { System.out.println(error: could not create logger layout pattern); System.out.println(e); System.exit(1); } // add pattern to file appender try { logFileAppender = new FileAppender(patternLayout, logFilename, false); traceFileAppender = new FileAppender(patternLayout, traceFilename, false); } catch (IOException e) { System.out.println(error: could not add logger layout pattern to corresponding appender); System.out.println(e); System.exit(1); } // add appenders to loggers logLogger.addAppender(logFileAppender); traceLogger.addAppender(traceFileAppender); // set logger level logLogger.setLevel(Level.INFO); traceLogger.setLevel(Level.INFO); // start logging server loggingServer = new LoggingServer(logLogger, traceLogger, serverPort, this); loggingServer.start(); System.out.println( done); } To make sure that only only thread is using the functionality of a logger instance at the same time each logging / tracing method calls the logging method .info() inside a synchronized-block. One example looks like this: public void logMessage(String message) { synchronized (logFileAppender) { if (logLogger.isInfoEnabled() logFileAppender != null) { logLogger.info(instanceName + : + message); } } } If I look at the log files, I see that sometimes a event appears in the wrong file. One example: trace 10:41:30,773 11080 INFO masterControl(192.168.2.21): string broadcast message was pushed from 1267093 to vehicle 1055293 (slaveControl 1) trace 10:41:30,784 11091 INFO masterControl(192.168.2.21): string broadcast message was pushed from 1156513 to vehicle 1105792 (slaveControl 1) trace 10:41:30,796 11103 INFO masterControl(192.168.2.21): string broadcast message was pushed from 1104306 to vehicle 1055293 (slaveControl 1) trace 10:41:30,808 5 INFO masterControl(192.168.2.21): vehicle 1327879 was pushed to slave control 1 10:41:30,808 5 INFO masterControl(192.168.2.21): string broadcast message was pushed from 1101572 to vehicle 106741 (slaveControl 1) trace 10:41:30,820 11127 INFO masterControl(192.168.2.21): string broadcast message was pushed from 1055293 to vehicle 1104306 (slaveControl 1) I think that the problem occures everytime two event happen at the same time (here: 10:41:30,808). Does anybody has an idea how to solve my problem? I already tried to add a sleep() after the method call, but that doesn't helped ... BR, Markus - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: using a different log4j.properties file per classes directory
which then causes all the tabs based logging to occur in a separate file (defined under the T log definition). The log entries from tabs are repeated into the root logger, which is not ideal but I can deal with. Have a look at the Additive property of logger/category, and set it to false (BTW: Logger and Category are semantically the same, the latter is older and deprecated. You should use Logger instead.) Heri - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: DailyRollingFileAppender RollingFileAppender after a rollover continues to write on previous file...
Problems with the rolling over behaviour occur mostly if more than one Appender write to the same file, e.g. out from different JVM's (since the file system cannot rename it if the other Appender still holds a handle on the file). Heri -Ursprüngliche Nachricht- Von: Roberto Simoni [mailto:roberto.sim...@yahoo.it] Gesendet: Freitag, 10. Juli 2009 11:38 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - DailyRollingFileAppender RollingFileAppender after a rollover continues to write on previous file... - Bayesian Filter detected spam Hi to all. We use log4j in a big project for our customer on a linux/unix system (JBoss 4, JDK 1.5). Every day, I see current time logs present in two log file... the current (application_name.log) and the previous log (application_name.log.date_pattern or application_name.log.counter) as the rollover operation hasn't stopped to write to the previous file. We have only a log4j.xml file and a file appender configured. What I see is that when the problem occurs a lot of logs is in writing in that moment. We have a batch operation at midnight, so with DailyRollingFileAppender the problem occurs everyday, instead with RollingFileAppender the problem occurs only if the rollover is made around midnight. I have seen that rollover operation is *not* synchronized due to a already synchronization on doAppend method (as sad in RollingFileAppender class). Are you confident on this behaviour? Thanks in advance Bye - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: What causes RollingFileAppender to not roll over
A common reason for not rolling over is that more than one appender instance write to the same file, i.e. more than one file handle are open on the same physical file. Heri -Ursprüngliche Nachricht- Von: DOUTCH GARETH-GDO003 [mailto:gareth.dou...@motorola.com] Gesendet: Montag, 29. Juni 2009 12:47 An: Log4J Users List Betreff: [SPAM (Bayesain Analysis)] - What causes RollingFileAppender to not roll over - Bayesian Filter detected spam Hi there, I have a number of machines where my RollingFileAppenders are not rolling over, resulting in huge log files. Is there any particular cause of this that I might be able to fix / avoid / workaround? Cheers, Gareth - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: turn off log messages in rootLogger which are supposed to end up in a named logger
Something like log4j.logger.PhasesLogger.additivity=false I am not quite sure about the correct syntax in properties file (I work always with xml files). The additivity flag of a logger prevents the loggin event to climb up further the logger hierarchy. Heri -Ursprüngliche Nachricht- Von: news [mailto:n...@ger.gmane.org] Im Auftrag von ossi petz Gesendet: Donnerstag, 25. Juni 2009 18:32 An: log4j-user@logging.apache.org Betreff: turn off log messages in rootLogger which are supposed to end up in a named logger hello I'm sorry for asking this boring question but after hours of experiments and even reading a (quite old) book I cant find a solution. So maybe someone can give me a hint what i am doing wrong. The plan is to have an application log file and a performanceLog file which contains only certain messages (PhasesLogger). At the moment the messages for the performanceLog end up in the root logger too. This is my log config: log4j.rootLogger=DEBUG,R log4j.logger.PhasesLogger=DEBUG,performanceLogger log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=/home/tomcat/tomcat/logs/log.log log4j.appender.R.MaxFileSize=1KB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d{ISO8601} [%-6p] %30c - %m%n # log4j.appender.R.threshold=ERROR # Performance Appender: log4j.appender.performanceLogger=org.apache.log4j.RollingFileAppender log4j.appender.performanceLogger.layout=org.apache.log4j.PatternLayout log4j.appender.performanceLogger.layout.ConversionPattern=%d{ISO8601} [%-6p] %14c - %m%n log4j.appender.performanceLogger.File=/home/tomcat/tomcat/logs/performanceLogger.log log4j.appender.performanceLogger.MaxFileSize=1KB log4j.appender.performanceLogger.MaxBackupIndex=10 # log4j.appender.performanceLogger.threshold=DEBUG The performanceLogger is retrieved like this: private static final Logger PLOG = Logger.getLogger(PhasesLogger); PLOG.debug(things...); how can i turn off to have the log messages for the phases/performanceLogger end up in the rootLogger file too? any hints are welcome! regards ossi - 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: - Log4j File appenders-generate files specified by appenders only in first usage
You cannot do this by configuration. What is the problem of having empty log files? Heri -Ursprüngliche Nachricht- Von: inosh [mailto:inosh...@gmail.com] Gesendet: Mittwoch, 24. Juni 2009 10:59 An: log4j-user@logging.apache.org Betreff: [SPAM (Keyword Checking)] - Log4j File appenders-generate files specified by appenders only in first usage - Found word(s) list error in the Text body Hi All, I'm little bit new to log4j. I have used log4j xml to configure file appenders and loggers. But i want to take some control over those appender file creation. All the files specified in fileAppenders are generating when loading log4j.xml. What i want is to generate those files only when the first usage of the loggers which have these files get append. For example if error.txt file is specied in some FileAppender, the file is creating when log4j.xml is loaded. But what want is to create those files only when the first usage of the logger which as this file as an Appender. This can be done by creating appenders in manually in code. But I was highly required to use log4j.xml. Please help me with this. Thanks. -- View this message in context: http://www.nabble.com/Log4j-File-appenders-generate-files-specified-by-appenders-only-in-first-usage-tp24181035p24181035.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
AW: [SPAM (Bayesain Analysis)] - Re: concurrency issues with one log file for multiple - Bayesian Filter detected spam
Be sure that all your Loggers use the same file appender (only once configured). The behaviour of several file appender instances writing to the same file (in different threads) is undefined and should be avoided. Heri -Ursprüngliche Nachricht- Von: Yair Ogen [mailto:yairo...@gmail.com] Gesendet: Sonntag, 21. Juni 2009 09:46 An: Log4J Users List Betreff: [SPAM (Bayesain Analysis)] - Re: concurrency issues with one log file for multiple - Bayesian Filter detected spam AFAIK. On Sun, Jun 21, 2009 at 10:31 AM, benedikt herudek benedikt.heru...@gmail.com wrote: I am using one logger per session and use the name of the logger to place in the log file, no nested diagnostic context. threadsafe in this context means: no blocking of whole file for one session, no building of queues I assume ... ? ... :-) regards Benedikt On Sun, Jun 21, 2009 at 8:36 AM, Yair Ogen yairo...@gmail.com wrote: log4j is thread safe and should handle the concurrency efficiently. I suggest you place tour OrderId in the log message using MDC. On Sat, Jun 20, 2009 at 12:12 PM, benedikt herudek benedikt.heru...@gmail.com wrote: Hi, we are intending to use log4J in a call center: we have around 100 simultaneous sessions working on one tool to create orders. W set up one logger per session (identified by basically the order id). All these loggers will write to one log file produced by log4J. Since we didnt use log4J before we want to be sure we are not creating concurrency issues and performance bottlenecks with having 100 session writing to one file. E.g. worst case scenario: 1st session loggs the file throughout its complete session and only releases it at the end, then in the meanwhile all other sessions queue up and wait. Rather, we suspect, log4J is automatically able to handle such a multiple sessions writing to one file situation and we dont have to bother with the details of that mechanism. Does anyone have experience, information, weblinks to documentation, tips or comments as to that problem ... ? ...:-) thx a lot !!! gruesse / regards / groetjes / adios Benedikt Herudek - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: Log4j : Read String from file
If fixed string means the string stays the same throughout the lifetime of the running application you can use the MDC. You add your string into the MDC at startup and reference its key within the layout pattern (X{key}). Heri -Ursprüngliche Nachricht- Von: durbans [mailto:m34890...@yahoo.it] Gesendet: Montag, 22. Juni 2009 12:24 An: log4j-user@logging.apache.org Betreff: Log4j : Read String from file Now I am logging this kind of string 2009-06-19 15:31:17,636 DEBUG with this ConversionPattern layout class=org.apache.log4j.PatternLayout /layout I'd like to insert a String like this 2009-06-19 15:31:17,636 YYMM_HHMMSS DEBUG where YYMM_HHMMSS is a fixed string read from a file. Is it possibile to do it ? How ? -- View this message in context: http://www.nabble.com/Log4j-%3A-Read-String-from-file-tp24144879p24144879.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
AW: [SPAM (Bayesain Analysis)] - Log file per thread - Bayesian Filter detected spam
Log4j distinguishes between Loggers and Appenders for a good reason: - Loggers define WHAT is logged (level, source) - Appenders define WHERE the log statement goes (console, file, etc.) and how it is formatted You want to have a new file for each new thread, so this is an appender issue which you cannot solve by creating a new appender. Of course you can create a Logger as you suggested, but then you have to pass this logger instance along your callstack (or make it globally accessible in the current thread context). If you do so you will loose most of the benefits which log4j offers. You implement then something like your own logging framework, a thing which to avoid was the main goal of inventing log4j. Follow the suggestion of Jake Kjome to search after this discussions in this mailing list and implement your RepositorySelector, based on MDC. There were even examples posted. Heri -Ursprüngliche Nachricht- Von: Kaspar Fischer [mailto:fisch...@inf.ethz.ch] Gesendet: Samstag, 2. Mai 2009 16:54 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - Log file per thread - Bayesian Filter detected spam Dear list, I am looking for a way to create a log file per thread (actually, per Quartz job that gets run). I've googled quite a bit and found a few approaches, in particular KeyFileAppender [1]. All I have seen seem to rely on the MDC and KeyFileAppender seems to have a resource leak [2]. I am wondering whether there is a simply way to programmatically create, at the beginning of my thread, a logger with a given name and closing it at the end of the thread. Has anybody accomplished something like this? public void run() { String id = ...; // thread name or whatever Logger logger = ...; // Create a logger with a basename and the id try { // ... } finally { logger.close(); // Something like this is needed to make sure // old logs do not keep hanging around } } Many thanks, Kaspar [1] https://issues.apache.org/bugzilla/show_bug.cgi?id=19597 [2] http://www.mail-archive.com/log4j-user@logging.apache.org/msg07295.html - 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: Access logfile logger
You cannot get access to the file object itself for reading purpose because the FileAppender uses a FileWriter class for writing to the file. But you can learn the file name where the appender writes to. Not each logger instance which you get by Logger.getLogger() has appenders attached. Only the logger instances whose name is exactly as a configured one have in fact the appenders attached as configured. So, if your logger instance has no RollingFileAppender attached, you would have to ask the parent logger, and so on, until you find the desired appender. Since the appenders instances are singleton, it would be easier to ask the LogManager for all appenders and iterate on these to find your desired RollingFileAppender. Once you have found the correct appender instance, you cast it and ask it for the file name for use in a file reader object. I am not sure about the lock mechanisme applied by a RollingFileAppender, if there are any. You have to try. Heri -Ursprüngliche Nachricht- Von: ja...@web.de [mailto:ja...@web.de] Gesendet: Montag, 4. Mai 2009 14:57 An: log4j-user@logging.apache.org Betreff: Access logfile logger Hi, I'm using log4j with a DailyRollingFileAppender. Now I want to add some reporting functions to the same application that uses this appender. So I need to get access to the logfile that is written by the file appender. Only the current logfile needs to be read so is is possible via the logger instance? Logger logger = Logger.getLogger(this.class); Regards, Jason __ GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT! Jetzt freischalten unter http://movieflat.web.de - 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: logging from another class
Hi In one of my projects I have implemented a swing TextPane Appender. See below the two classes JTextPaneAppender and JLogoutputFrame. The first one was copied (and enhanced) from a sample I found in the contribs package (but which did not work properly). The second one is a standalone window which shows the usage of the appender (which is created and configured by code). It is derived from Runnable in order to run in ist own thread. I have no time to enhance the classes in order to have this appender full configurable by log4j config files. If you want, you can do anything with it as you like. There are a numer of TODO's within the code indicating which enhancements I would implement next. Heri package .swingExtensions.log4j; import java.awt.Color; import java.util.Enumeration; import java.util.Hashtable; import javax.swing.JTextPane; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.Layout; import org.apache.log4j.Level; import org.apache.log4j.helpers.LogLog; import org.apache.log4j.spi.Filter; import org.apache.log4j.spi.LoggingEvent; /** * Implements a log4j appender which writes to a swing JTextPane * * This code was copied from * jakarta-log4j-1.2.15\apache-log4j-1.2.15\contribs\SvenReimers\gui\TextPaneAppender.java * (which did not work properly, not even compile) and adapted for my needs. * * @author bender */ public class JTextPaneAppender extends AppenderSkeleton { /** */ JTextPane myTextPane; /** */ HashtableString,MutableAttributeSet myAttributeSet; /** * Constructor * * @param aLayout * @param aName * @param aFilterArray * @param aTextPane */ public JTextPaneAppender( Layout aLayout, String aName, Filter[] aFilterArray, JTextPane aTextPane ) { this(); this.layout = aLayout; this.name = aName; myTextPane = aTextPane; if ( aFilterArray != null ) { for ( int i = 0; i aFilterArray.length; i++ ) { if ( aFilterArray[i] != null ) { addFilter( aFilterArray[i] ); } // if aFilterArray[i] != null] } // for i } // if aFilterArray != null createAttributes(); } /** * Constructor * */ public JTextPaneAppender() { super(); createAttributes(); } /** * @see org.apache.log4j.AppenderSkeleton#close() */ @Override public void close() { // } private void createAttributes() { String prio[] = new String[6]; prio[0] = Level.FATAL.toString(); prio[1] = Level.ERROR.toString(); prio[2] = Level.WARN.toString(); prio[3] = Level.INFO.toString(); prio[4] = Level.DEBUG.toString(); prio[5] = Level.TRACE.toString(); myAttributeSet = new HashtableString,MutableAttributeSet(); for ( int i = 0; i prio.length; i++ ) { MutableAttributeSet att = new SimpleAttributeSet(); myAttributeSet.put( prio[i], att ); StyleConstants.setFontSize( att, 14 ); } StyleConstants.setForeground(myAttributeSet.get(Level.FATAL.toString()),Color.red); StyleConstants.setForeground(myAttributeSet.get(Level.ERROR.toString()),Color.red); StyleConstants.setForeground(myAttributeSet.get(Level.WARN.toString()),Color.orange); StyleConstants.setForeground(myAttributeSet.get(Level.INFO.toString()),Color.black); StyleConstants.setForeground(myAttributeSet.get(Level.DEBUG.toString()),Color.black); StyleConstants.setForeground(myAttributeSet.get(Level.TRACE.toString()),Color.black); } /** * @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent) */ @Override public void append( LoggingEvent event ) { if ( myTextPane == null ) { LogLog.warn( TextPane is not initialized ); return; } // if myTextPane == null String text = this.layout.format( event ); String[] stackTrace = event.getThrowableStrRep(); if ( stackTrace != null ) { StringBuffer sb = new StringBuffer( text ); for ( int i = 0; i stackTrace.length; i++ ) { sb.append( ).append( stackTrace[i] ).append( \n ); } // for i text = sb.toString(); } StyledDocumentmyDoc = myTextPane.getStyledDocument(); try { myDoc.insertString(
AW: Newbie questions
If you do not specify any appender, your log message will go nowhere. Please read first the basics about log4j, before asking such dumb questions. Search the web for log4j tutorial and you will find tons of instructions and examples. Heri -Ursprüngliche Nachricht- Von: John El [mailto:jo...@mailinator.com] Gesendet: Dienstag, 7. April 2009 23:15 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - Newbie questions - Bayesian Filter detected spam can someone tell me where fatal messages go if this is in my config file? root priority value=fatal/ /root also can someone point me to a resource that describes all the potential arguments in this file for category and appender xml elements? TIA John -- View this message in context: http://www.nabble.com/Newbie-questions-tp22938434p22938434.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
AW: Configure custom logger from file
Already looked at the LoggerFactory? Heri -Ursprüngliche Nachricht- Von: Yair Ogen [mailto:yairo...@gmail.com] Gesendet: Donnerstag, 2. April 2009 10:13 An: log4j-user@logging.apache.org Betreff: Configure custom logger from file Hi, I need to configure a custom Legger that extends then log4j Logger. I want users to code: Logger.getLogger, and get the custom logger. I know how to do this in code, but this will require every developer to call this code. I want to find a way to this via the log4.properties file so if all developers use the same file their code is clean and will use the custom logger in a transparent way. Any ideas? Thanks. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: [SPAM (Bayesain Analysis)] - 'DailyRollingFileAppender' problem - two process, one log4j.properties file - Bayesian Filter detected spam
Two JVM logging to the same file is a MUST NOT. Heri -Ursprüngliche Nachricht- Von: yokese [mailto:fastturtle...@gmail.com] Gesendet: Montag, 16. März 2009 13:35 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - 'DailyRollingFileAppender' problem - two process, one log4j.properties file - Bayesian Filter detected spam Hi everydoby I'm having a extrange behaviour with a log4j configuration. I have two different process running from two different java virtual machines. Both of then read their log4j configuration from the same configuration file: -- log4j.rootCategory=DEBUG log4j.logger.FileChecker=DEBUG,FileChecker log4j.logger.AlertChecker=DEBUG,AlertChecker # # FileChecker is a DailyRollingFileAppender # log4j.appender.FileChecker=org.apache.log4j.DailyRollingFileAppender log4j.appender.FileChecker.file=./log/mylogRecibir.log log4j.appender.FileChecker.datePattern='.'-MM-dd log4j.appender.FileChecker.append=true log4j.appender.FileChecker.layout=org.apache.log4j.PatternLayout log4j.appender.FileChecker.layout.ConversionPattern=[%c] %-5p %d{ISO8601} - %m%n # # AlertChecker is a DailyRollingFileAppender # log4j.appender.AlertChecker=org.apache.log4j.DailyRollingFileAppender log4j.appender.AlertChecker.file=./log/mylogSend.log log4j.appender.AlertChecker.datePattern='.'-MM-dd log4j.appender.AlertChecker.append=true log4j.appender.AlertChecker.layout=org.apache.log4j.PatternLayout log4j.appender.AlertChecker.layout.ConversionPattern=[%c] %-5p %d{ISO8601} - %m%n -- (in both of the process java code I do: private static Logger logger = Logger.getLogger(AlertChecker); . PropertyConfigurator.configure(IPegasoProperties.IPEGASO_PROPERTIES_FILE); //the logj4j configuration file ) It happens that when day changes old logging files are not renamed properly; instead they are overwritten. Also, when log files are from an older day (process are stopped); the first process I start roll the log file properly, but the second overwrite his log (don't do the roll). I'm tested new versions and log4j and the problem is the same. Could anybody help me? -- View this message in context: http://www.nabble.com/%27DailyRollingFileAppender%27-problem---two-process%2C-one-log4j.properties-file-tp22537011p22537011.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
AW: How to filter the unnecessary log messages
Either you strongly restrict the level of your root logger (e.g. ERROR) and declare a logger for your own classes with DEBUG level: logger name=my.company additivity=false level value=DEBUG/ (appender-refs) /logger root level value=ERROR/ (appender-refs) /root Or you go the other way round, you restrict the library loggers strongly and configure the root logger to DEBUG: logger name=org.springframework additivity=false level value=WARN/ (appender-refs) /logger logger name=org.hibernate additivity=false level value=ERROR/ (appender-refs) /logger logger name=org.hibernate additivity=false level value=info/ (appender-refs) /logger logger name=org additivity=false level value=info/ (appender-refs) /logger root level value=DEBUG/ (appender-refs) /root -Ursprüngliche Nachricht- Von: Harikrishna Imadabattina [mailto:harikrishna.imadabatt...@techendeavour.com] Gesendet: Montag, 9. März 2009 12:58 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - How to filter the unnecessary log messages - Bayesian Filter detected spam Hi all, I have implemented log4j and it works well. But the application had Struts2, Spring,Hibernate,Tiles and other open source components. When I start the tomcat or run the application the log file gets filled with so many logs which are there inside jars of these frameworks. Can any one please let me know how can I filter out those messages and enable only application specific messages to appear in the log file. Please find the log pasted below. Thanks Harry - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: [SPAM (Bayesain Analysis)] - Using log4j.properties to handle other properties - Bayesian Filter detected spam
I assume you mean following (pseudo code) If SystempropertyCollectStatistics==True myLog.info( ... ) The correct way would be to use a special named logger and declare it in the propeties file with the desired log level. Possible code in class with statstic logging needs: Logger myNormalDebugLogger = Logger.getLogger( CLASS ); Logger myStatisticLogger = Logger.getLogger( StatisticLogger ) static int count = 0; void foo() myNormalDebugLogger.debug( entering foo()... ); count++; if myStatisticLogger.isInfoEnabled() myStatisticLogger.info( foo() called now + count + times ); ... Within the configuration file you can enable the statistics by setting the level of StatisticLogger to INFO, disable it by setting it to WARN or OFF. Heri -Ursprüngliche Nachricht- Von: Christophe Elek [mailto:ce...@ca.ibm.com] Gesendet: Montag, 9. März 2009 15:09 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - Using log4j.properties to handle other properties - Bayesian Filter detected spam My developers are using System Properties to enable certain trace options (like collecting statistics) Is there a way I could define such property in the log4j.properties instead so we keep trace/log options and metadata together ? So my developers will do aLog 4J object.getProperty('my property') instead of System.getProperty() ? Christophe Elek - Senior Software Analyst IBM Rational Serviceability Architect IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7 Phone Number: (905) 413-3467 Email: ce...@ca.ibm.com Rational Internal Serviceability Portal Don't just fix the mistakes - fix whatever permitted the mistake in the first place. Charles Fishman Web:http://www.ibm.com/software/rational/ - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: Logging issue with logginf to seperate log files
The config file seems to be OK (BTW: You should use the tag logger instead of category which is deprecated). How do you fetch the logger instance in LoadCommonData? You should use Logger.getLogger( LoadCommonData.class ). For debugging log4j, add the attribute debug to the root tag: log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=true Or you can supply a command line argument when starting the app: -Dlog4j.debug for getting additinal infos how log4j is configured. Heri -Ursprüngliche Nachricht- Von: Ashish Kulkarni [mailto:ashish.kulkarn...@gmail.com] Gesendet: Montag, 23. Februar 2009 21:59 An: Log4J Users List Betreff: Logging issue with logginf to seperate log files HiI have a web application where the class structure is as below com.test.myproject.common I have a class under package common, i want to print all the logs from this log file to a separate log file, so i defined log4j.xml file as below. For some reason all the logs are logged in log4jXml.xml and in STDOUT, but log file StartUpInfo.log is empty what am i doing wrong, is there a way to debug log4j itself appender name=A1 class=org.apache.log4j.DailyRollingFileAppender param name=File value=/mylog/log4jXml.xml / param name=DatePattern value='.'-MM-dd / layout class=org.apache.log4j.xml.XMLLayout/layout /appender appender name=A2 class=org.apache.log4j.FileAppender param name=File value=/mylog/StartUpInfo.log / layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d %-5p [%t] %C{2} (%F:%L) - %m%n / /layout /appender appender name=STDOUT class=org.apache.log4j.ConsoleAppender layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d %-5p [%t] %C{2} (%F:%L) - %m%n / /layout /appender category name=com.test.myproject priority value=debug / appender-ref ref=A1 / /category category name=com.test.myproject.common.LoadCommonData additivity=false priority value=debug / appender-ref ref=A2 / /category root priority value=DEBUG/priority appender-ref ref=STDOUT / /root - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: Log Debug and Info in 2 different files
I think it is not necessary to use Filters as Curt suggested since you dont want to have an upper limit of the levels. Add the threshold property to the appender declaration. Your problem is that you have defined two loggers with the same name. I assume that the second one overwrites the first one during configuration. Just declare one logger (without level property) and attach both appenders to it. BTW: You should also declare a root logger for all other log statements. logger name=com.in.en.ef.sw additivity=false appender-ref ref=SWITCH_LOG/ appender-ref ref=SWITCH_LOG_1/ /logger Heri -Ursprüngliche Nachricht- Von: Mohit Anchlia [mailto:mohitanch...@gmail.com] Gesendet: Donnerstag, 12. Februar 2009 23:30 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - Log Debug and Info in 2 different files - Bayesian Filter detected spam I am trying to log DEBUG and up in one log file and INFO and up in other log file. But it doesn't seem to be working. I have tried various things like Level, Threshold, additivity, Priority etc. Nothing seems to be working. Nothing is being written to sw.log. Only INFO and up is being written to sw_infoerr.log. I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log Below is the config: ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=false appender name=SWITCH_LOG class=org.apache.log4j.RollingFileAppender param name=File value=/usr/local/tomcat/logs/sw.log/ param name=Append value=true/ !-- Keep 50 logs, 50MB each -- param name=MaxBackupIndex value=50/ param name=MaxFileSize value=52428800/ param name=DatePattern value='.'-MM-dd/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{ISO8601} %-5p [%c{3}:%t] - %m%n/ /layout /appender appender name=SWITCH_LOG_1 class=org.apache.log4j.RollingFileAppender param name=File value=/usr/local/tomcat/logs/sw_infoerr.log/ param name=Append value=true/ !-- Keep 50 logs, 50MB each -- param name=MaxBackupIndex value=50/ param name=MaxFileSize value=52428800/ param name=DatePattern value='.'-MM-dd/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{ISO8601} %-5p [%c{3}:%t] - %m%n/ /layout /appender logger name=com.in.en.ef.sw additivity=false appender-ref ref=SWITCH_LOG/ /logger logger name=com.in.en.ef.sw additivity=false level value=INFO/ appender-ref ref=SWITCH_LOG_1/ /logger /log4j:configuration - 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: Log Debug and Info in 2 different files
What is the problem? The below configuration seems OK, if you replace the ... by the other needed parameters (file, layout, etc). You can put debug=true to see on the console how log4j configures itself. Heri -Ursprüngliche Nachricht- Von: Steve Cohen [mailto:sco...@javactivity.org] Gesendet: Montag, 16. Februar 2009 19:50 An: Log4J Users List Betreff: [SPAM (Bayesain Analysis)] - Re: Log Debug and Info in 2 different files - Bayesian Filter detected spam I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log Why would this not work? ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=false appender name=SWITCH_LOG class=org.apache.log4j.RollingFileAppender param name=Threshold value=DEBUG/ ... /appender appender name=SWITCH_LOG_1 class=org.apache.log4j.RollingFileAppender param name=Threshold value=INFO/ ... /appender logger name=com.in.en.ef.sw additivity=false appender-ref ref=SWITCH_LOG/ appender-ref ref=SWITCH_LOG_1/ /logger /log4j:configuration Mohit Anchlia wrote: I am trying to log DEBUG and up in one log file and INFO and up in other log file. But it doesn't seem to be working. I have tried various things like Level, Threshold, additivity, Priority etc. Nothing seems to be working. Nothing is being written to sw.log. Only INFO and up is being written to sw_infoerr.log. I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log Below is the config: ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=false appender name=SWITCH_LOG class=org.apache.log4j.RollingFileAppender param name=File value=/usr/local/tomcat/logs/sw.log/ param name=Append value=true/ !-- Keep 50 logs, 50MB each -- param name=MaxBackupIndex value=50/ param name=MaxFileSize value=52428800/ param name=DatePattern value='.'-MM-dd/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{ISO8601} %-5p [%c{3}:%t] - %m%n/ /layout /appender appender name=SWITCH_LOG_1 class=org.apache.log4j.RollingFileAppender param name=File value=/usr/local/tomcat/logs/sw_infoerr.log/ param name=Append value=true/ !-- Keep 50 logs, 50MB each -- param name=MaxBackupIndex value=50/ param name=MaxFileSize value=52428800/ param name=DatePattern value='.'-MM-dd/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{ISO8601} %-5p [%c{3}:%t] - %m%n/ /layout /appender logger name=com.in.en.ef.sw additivity=false appender-ref ref=SWITCH_LOG/ /logger logger name=com.in.en.ef.sw additivity=false level value=INFO/ appender-ref ref=SWITCH_LOG_1/ /logger /log4j:configuration - 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: sending output from separate java packages to separate files
Additivity in Properties file: Log4j.additivity.loggername=false See also page 53 in Manual. Heri -Ursprüngliche Nachricht- Von: Pat Farrell [mailto:pfarr...@pfarrell.com] Gesendet: Dienstag, 17. Februar 2009 06:32 An: Log4J Users List Betreff: [SPAM (Bayesain Analysis)] - Re: sending output from separate java packages to separate files - Bayesian Filter detected spam Curt Arnold wrote: You define appenders named stdout, baz and foo, then you attach appenders named Thanks. I tried to edit the property file to protect the innocent, and mangled it. Since base and stripesfile are not defined, the only place for the messages to go is to stdout. Actually, they were always going to one of the log files. But you pointed me in the right direction. Thanks My real problem was that Netbeans was putting the log4j.properties file in the sublibrary, and it was getting read first. Since you are not setting additivity to false, all messages sent to com.foo.* will be sent to stdout twice, once for its attachment at com.foo and once for its attachment to the rootLogger. I've read and re-read the complete manual, and I think I get the concept of additivity but I don't understand how to control them in the properties file. Is there a source for more examples of log4j.properties files and options, syntax, etc? The manual has lots more on XML formats and controlling it from within Java than it has on simple properties. Even the Wiki seems to not have much (or much I can find) on properties files. Where possible, I much prefer good ol Java properties files. Thanks Pat -- Pat Farrell http://www.pfarrell.com/ - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: which mail that I can send my questions to?
This is the correct list for questions about using log4j. Heri -Ursprüngliche Nachricht- Von: 刘永辉 [mailto:yh...@cn.ufinity.com] Gesendet: Dienstag, 10. Februar 2009 06:19 An: log4j-user Betreff: [SPAM (Bayesain Analysis)] - which mail that I can send my questions to? - Bayesian Filter detected spam Hi if I have some questions, which email address I can send to? this? or? Regards Yonghui Best Regards yongHui -- Yonghui Lau Ufinity (China )Pte Ltd Email: yh...@cn.ufinity.com| Web:http://www.ufinity.com | Tel/Fax: 0551-2832378/2832377-806 Address 436#5003Changjiang Road,HeFei City,An Hui Province ,China - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: Load a log4j.xml located within a package - how?
Maybe there exists indeed a file C:\Programme\Mozilla Firefox\de\xyz\...\log4j.xml which is found first by the classloader? Then try getResources() to get an enumeration of all resources found. Or try getSystemResource() of the classloader. Heri -Ursprüngliche Nachricht- Von: Linnemann, Gerrit [mailto:linnem...@hesgdv.de] Gesendet: Dienstag, 10. Februar 2009 07:31 An: log4j-user@logging.apache.org Betreff: Load a log4j.xml located within a package - how? Hallo, I'm trying to load a separate config file (log4j.xml) within a jar-File. It is an applet and I want to load a config file located within a package. I tried it like this: URL path2Conf = this.getClass().getClassLoader().getResource(de/xyz/log4j/applets/log4j.xml); DOMConfigurator.configure(path2Conf); But the java console of the browser says, the DOMConfigurator wants to load the XML from C:\Programme\Mozilla Firefox\de\xyz\...\log4j.xml The same with: String path2Conf = System.getProperty(user.dir) + File.separator + de\\hes\\log4j\\applets\\log4j.xml; DOMConfigurator.configure(path2Conf); Has anyone an Idea how to load a config file located within a package? Thanking you in anticipation, Gerrit - 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: difference between using properties file and XML file to loading log4j preferences
XML is the newer technology. Property files are not guaranteed to be supported for all upcoming features. E.g. in XML you can use Filter in appender definitions which you can't use in Property files. Heri -Ursprüngliche Nachricht- Von: Ashish Kulkarni [mailto:ashish.kulkarn...@gmail.com] Gesendet: Dienstag, 10. Februar 2009 17:01 An: Log4J Users List Betreff: [SPAM (Bayesain Analysis)] - difference between using properties file and XML file to loading log4j preferences - Bayesian Filter detected spam HiWhat is the difference between loading properties file and XML file to load logj4 preference, is there any advantages or disadvantages of doing so? - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: Redirect system.out into FileAppende
I suggest to implement a specialized OutputStream which writes to the file appender (or directly to the file appender's file, if no threading issue arise). Then replace the default System.out and System.err streams by this specialized stream. Heri -Ursprüngliche Nachricht- Von: thomas.th.hamac...@partner.bmw.ch [mailto:thomas.th.hamac...@partner.bmw.ch] Gesendet: Donnerstag, 8. Januar 2009 14:06 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - Redirect system.out into FileAppender - Bayesian Filter detected spam Hi, is it possible to redirect the normal system.out or system.err into a FileAppender defined through log4j. I have the problem that I´m using a 3rd-party application, that uses System.out.println() in it´s code and I´d like to combine this with my other log4j-configurations into one single file currently defined through a FileAppender. Any idea how to do that? Thanks Thomas - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: [SPAM (Bayesain Analysis)] - I need to make logging in a complete application - Bayesian Filter detected spam
I am not quite shure what you want to do. Do you want to leave all System.out.println calls in your code? If so, you do not need log4j to redirect them. Just redirect the System.out Outputstream to a stream of your like. If you want to use log4j, you have to replace all System.out calls with the appropriate log4j calls, and configure the desired appenders through the configuration file. Heri -Ursprüngliche Nachricht- Von: Ariel [mailto:isaacr...@gmail.com] Gesendet: Freitag, 26. Dezember 2008 15:29 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - I need to make logging in a complete application - Bayesian Filter detected spam Hi everybody: I am newbie with log4j, I have made a distributed and multithreaded application where all the logging is made displaying de mesagges in the console using System.out.println. Now I want to redirect those messages to a file to have a trace of all the messages. Is there anyway to telling log4j that all the System.out messages write them into a file ??? Please could you help me ? Regards Ariel - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
AW: SMTPAppender
Try a standalone tool in order to open this socket. E.g. castalia socktest (free download), or even telnet in your command prompt: Telnet host port heri -Ursprüngliche Nachricht- Von: Massimo Quagliani [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 4. Dezember 2008 18:02 An: Log4J Users List Betreff: RE: SMTPAppender Please, could you explain in detail what you would do in this situation? I didn't figure out your suggestion. /Max -Original Message- From: Joe White [mailto:[EMAIL PROTECTED] Sent: giovedì 4 dicembre 2008 17.45 To: log4j-user@logging.apache.org Subject: RE: SMTPAppender The error is clear in the stacktrace. java.net.ConnectException: Connection timed out: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391) I do not think it's log4j related.. Can you make the connection on your box via telnet or some other type of email program ? Quoting Massimo Quagliani [EMAIL PROTECTED]: Thanks, But I changed my log4j.properties file using another SMTP host, which, according to this link http://www.velociraptus.com/internet/articoli_d.php?particoloID=27 uses port 25 for SMTP (it is in italian but in the table it is clear the port is 25). The error is still there... Please help!! /Massimo # Email appender log4j.appender.email=org.apache.log4j.net.SMTPAppender log4j.appender.email.BufferSize=25 log4j.appender.email.SMTPHost=mail.libero.it log4j.appender.email.SMTPUsername=valid_username log4j.appender.email.SMTPPassword=valid_password [EMAIL PROTECTED] [EMAIL PROTECTED] log4j.appender.email.Subject=Error log4j.appender.email.layout=org.apache.log4j.PatternLayout log4j.appender.email.layout.ConversionPattern= %d{DATE} %-5p %m - %c{3} [%t] [%r ms]%n%n log4j.appender.email.threshold=ERROR The stack trace is the same... 2008-12-04 09:28:17,515 ERROR [http-8080-2] : This is a try! log4j:ERROR Error occured while sending e-mail notification. javax.mail.MessagingException: Could not connect to SMTP host: mail.libero.it, port: 25; nested exception is: java.net.ConnectException: Connection timed out: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412) at javax.mail.Service.connect(Service.java:310) at javax.mail.Service.connect(Service.java:169) at javax.mail.Service.connect(Service.java:118) at javax.mail.Transport.send0(Transport.java:188) at javax.mail.Transport.send(Transport.java:118) at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:330) at org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:215) at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251) at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66) at org.apache.log4j.Category.callAppenders(Category.java:206) at org.apache.log4j.Category.forcedLog(Category.java:391) at org.apache.log4j.Category.error(Category.java:305) at servlet.Log4jServlet.doGet(Log4jServlet.java:80) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown
AW: [SPAM (Keyword Checking)] - RE: SMTPAppender - Found word(s) list error in the Text body
As far as I know this command just opens a socket: Host:port. No protocol is anticipated. If your machine cannot open this socket connection then something might be wrong with your network, firewall, gateway, etc. This is shurly not related to log4j. Heri -Ursprüngliche Nachricht- Von: Massimo Quagliani [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 4. Dezember 2008 19:35 An: Log4J Users List Betreff: [SPAM (Keyword Checking)] - RE: SMTPAppender - Found word(s) list error in the Text body I tried: telnet mail.libero.it 25 Trying 212.52.84.54... telnet: Unable to connect to remote host: Connection timed out But I have a stupid question, using telnet my client is expected to find a telnet server on the port 25, while there should be an smtp server. Am I wrong? /MAx -Original Message- From: Bender Heri [mailto:[EMAIL PROTECTED] Sent: giovedì 4 dicembre 2008 19.11 To: Log4J Users List Subject: AW: SMTPAppender Try a standalone tool in order to open this socket. E.g. castalia socktest (free download), or even telnet in your command prompt: Telnet host port heri -Ursprüngliche Nachricht- Von: Massimo Quagliani [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 4. Dezember 2008 18:02 An: Log4J Users List Betreff: RE: SMTPAppender Please, could you explain in detail what you would do in this situation? I didn't figure out your suggestion. /Max -Original Message- From: Joe White [mailto:[EMAIL PROTECTED] Sent: giovedì 4 dicembre 2008 17.45 To: log4j-user@logging.apache.org Subject: RE: SMTPAppender The error is clear in the stacktrace. java.net.ConnectException: Connection timed out: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391) I do not think it's log4j related.. Can you make the connection on your box via telnet or some other type of email program ? Quoting Massimo Quagliani [EMAIL PROTECTED]: Thanks, But I changed my log4j.properties file using another SMTP host, which, according to this link http://www.velociraptus.com/internet/articoli_d.php?particoloID=27 uses port 25 for SMTP (it is in italian but in the table it is clear the port is 25). The error is still there... Please help!! /Massimo # Email appender log4j.appender.email=org.apache.log4j.net.SMTPAppender log4j.appender.email.BufferSize=25 log4j.appender.email.SMTPHost=mail.libero.it log4j.appender.email.SMTPUsername=valid_username log4j.appender.email.SMTPPassword=valid_password [EMAIL PROTECTED] [EMAIL PROTECTED] log4j.appender.email.Subject=Error log4j.appender.email.layout=org.apache.log4j.PatternLayout log4j.appender.email.layout.ConversionPattern= %d{DATE} %-5p %m - %c{3} [%t] [%r ms]%n%n log4j.appender.email.threshold=ERROR The stack trace is the same... 2008-12-04 09:28:17,515 ERROR [http-8080-2] : This is a try! log4j:ERROR Error occured while sending e-mail notification. javax.mail.MessagingException: Could not connect to SMTP host: mail.libero.it, port: 25; nested exception is: java.net.ConnectException: Connection timed out: connect at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412 ) at javax.mail.Service.connect(Service.java:310) at javax.mail.Service.connect(Service.java:169) at javax.mail.Service.connect(Service.java:118) at javax.mail.Transport.send0(Transport.java:188) at javax.mail.Transport.send(Transport.java:118) at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:330) at org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:215) at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251) at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders( AppenderAttachableImpl.java:66) at org.apache.log4j.Category.callAppenders(Category.java:206) at org.apache.log4j.Category.forcedLog(Category.java:391) at org.apache.log4j.Category.error(Category.java:305) at servlet.Log4jServlet.doGet(Log4jServlet.java:80) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli cationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi lterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa lve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa lve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja va:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja va:102
AW: [SPAM (Bayesain Analysis)] - Repository selectors, useful? - Bayesian Filter detected spam
Hallo Ceki I found log4j's RepositorySelector very useful, I think I would not have been able to solved my problem without it. I use it in a System which is designed to maintain different customers. A single customer should never see any data (or even know about the existence) of other customers. So I needed to separate also all logs. One core application is a scheduler app which maintains different jobs which run at regular intervals (configured for each customer and job kind). The jobs make heavy use of common libraries (in fact most of the work is done within these libraries, which make a lot of log outputs). This log outputs should never mix between customers and jobs. Such a job is running in its own thread. Therefore I can use the MDC which is feeded at every thread start with infos about the current job and the current customer. This info is then used by the repository selector for choosing the correct repository (where file appenders are defined with filenames and storage locations mirroring these MDC infos). Maybe your new logback has other useful constructs to solve such a problem. Using Log4j's RepositorySelector was a bit hard to understand at the beginning, specially the need for having special logging code (MDC, configuring the file appenders) at every thread start (was a bit complex in combination with a thread pooling). I wished that such things could be done only by configuration. More problems: Logger instances in library classes cannot be instantiated statically, and utility classes with static methods and other singletons must fetch the logger on each method entry (I had to disable log outputs from third party libraries which do not obey such circumstances). Greetings Heri Bender -Ursprüngliche Nachricht- Von: Ceki Gulcu [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 26. Dezember 2008 14:06 An: Log4J Users List Betreff: [SPAM (Bayesain Analysis)] - Repository selectors, useful? - Bayesian Filter detected spam Hello, I am in the process of fixing bugs related to context selectors in logback. Context selectors are the equivalent of repository selectors in log4j. However, while few years back I thought that context selectors, aka repository selectors, were the wave of the future, I am increasingly skeptical about their usefulness. If you are using context/repository selectors, could you please explain why? -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch - 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]
AW: no appenders could be found for logger, but I think I have set the classpath!
You should only define the path and not also the file: CLASSPATH=%CLASSPATH%;C:\eclipse\workspace\monitor\monitorClient\src\config Instead of CLASSPATH=%CLASSPATH%;C:\eclipse\workspace\monitor\monitorClient\src\config\log4j.xml -Ursprüngliche Nachricht- Von: raybristol [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 17. September 2008 05:23 An: log4j-user@logging.apache.org Betreff: no appenders could be found for logger, but I think I have set the classpath! Hi experts, I got a very common problem: no appenders could be found for logger I was search the answer online, I can see this is caused by not setting the log4j.xml (or properties) file in classpaths, however I think I set it, if I do each %CLASSPATH%, then I can see log4j.xml is in there, I even use the absolute path, my environment is windows, and I was trying to run my application using a bat file: set CLASSPATH=../classes set CLASSPATH=%CLASSPATH%;../lib/sprsCommon-dev.jar set CLASSPATH=%CLASSPATH%;../lib/commons-lang-2.0.jar set CLASSPATH=%CLASSPATH%;../lib/commons-logging-1.0.3.jar set CLASSPATH=%CLASSPATH%;../lib/commons-validator.jar set CLASSPATH=%CLASSPATH%;../lib/log4j-1.2.8.jar set CLASSPATH=%CLASSPATH%;../lib/quartz.jar set CLASSPATH=%CLASSPATH%;../lib/ojdbc14.jar rem log4j properties file set CLASSPATH=%CLASSPATH%;C:\eclipse\workspace\monitor\monitorClient\src\config\log4j.xml set MONITOR_CONFIG_DIR=C:\eclipse\workspace\monitor\monitorClient\src set JAVA_MONITOR_OPTS=-Xms128m -Xmx256m -Dfile.encoding=big5-HKSCS set JAVA_MONITOR_OPTS=%JAVA_MONITOR_OPTS% -Dmonitor.config.filename=%MONITOR_CONFIG_DIR%/config/monitorClient.properties %JAVA% -classpath %CLASSPATH% %JAVA_MONITOR_OPTS% com.hongyip.monitor.report.facade.TestReportServerMonitorManager Many thanks for your help here!!! -- View this message in context: http://www.nabble.com/no-appenders-could-be-found-for-logger%2C-but-I-think-I-have-set-the-classpath%21-tp19524733p19524733.html Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: Logger object and change filename
At the code location where a particular Thread knows about processing a distinct element you put a identifying information into MDC, after having processed remove the info again. MDC values are kept on a per Thread basis. This info can be used by the MultifileAppender (when processing a log call) or by a own written Repository Selector (when fetching a logger). Heri -Original Message- From: Reza Razavipour [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 09, 2008 7:09 PM To: Log4J Users List Subject: Re: [SPAM (Bayesain Analysis)] - Logger object and change filename - Bayesian Filter detected spam I have, I just don't see how that works for my case??? Reza On Tue, Sep 9, 2008 at 9:28 AM, Jacob Kjome [EMAIL PROTECTED] wrote: Search the list for MultiFileAppender or something to the effect of per-thread logging based on MDC values. Jake On Tue, 9 Sep 2008 09:00:53 -0700 Reza Razavipour [EMAIL PROTECTED] wrote: Ok, let me explain more... I have a set of elements, a queue of them...I have a thread pool of processors. A processor takes an element from the queue and logs some information about them. So what I need to do is to log the information about element XYZ to a file called XYZ.log and for element ABC to the file ABC.log and on and on... From the log4j.xml for the app, there is an appender called AllElements, lets say. In addition to all element specific log files, I need to log to this file also...Now what I need to do is to clone. If it is a rollingFileAppender the element specific log appender needs to be the same, the pattern format should be the same, the only difference is appender file name... So for each element, I need a brand new logger with appenders exactly the same as the one defined in log4j.xml file, the only difference is the filename for the appender, there is only one. Does this help at all clarify what I need to do? Thanks Reza On Tue, Sep 9, 2008 at 8:00 AM, Bender Heri [EMAIL PROTECTED] wrote: Loggers do not have file names attached. Probably you mean a FileAppender. Each configured Appender is instantiated as singleton, even if it is attached to more than one Logger. Loggers are identified by a arbitrary String, commonly the FQCN. Therefore you cant clone a Logger which has the same name as the original. Explain more about your needs. Why do you have to clone it? Heri -Original Message- From: Reza Razavipour [mailto:[EMAIL PROTECTED] Sent: Monday, September 08, 2008 5:38 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Logger object and change filename - Bayesian Filter detected spam All, I have a Logger object and I need to create a clone of it and change its filename to a different name. How does one do that? The idea here is that I have initialized a Logger instance from log-4j.xml file. Now I need to create a new one, off of it or clone and change the filename. Every attribute of the new Logger instance should be whatever is in the file, only filename is diifferent. Thanks in advance. Reza --- -- 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] - 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] - 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]
RE: [SPAM (Bayesain Analysis)] - RE: static log4j configuration statement - Bayesian Filter detected spam
Just put your property file into the classpath and you do not have to worry about initialization of log4j framework. It does it automagically when you fetch the first logger. Heri -Original Message- From: Michael Erskine [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 10, 2008 4:20 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - RE: static log4j configuration statement - Bayesian Filter detected spam I use standard static code to include the log4j configuration: static { PropertyConfigurator.configure(file)); } But this code is not always executed, depending on if the class in which this is included particpates in execution. But if I add this statment to other classes too, I sooner or later get double-messages as two classes with this statement are used. Then I need to manually remove the code in one of them to achieve proper logging. How this is done right? I just want to have this configuration stated once and applicable to the whole project. Hi Sebastian, What I tend to do is have a class to do something similar but first check whether already configured: my class is called LogConfigureCheck and is used in a static block for all my JUnit tests thus... static { LogConfigureCheck.check(); } ...and here follows a version of the class suitable for redistribution. Enjoy, Michael Erskine import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; /** * Occasionally we find a JUnit test suite or test case class that tests classes * that use log4j but for whatever reason log4j is not configured. We want to * avoid log4j being configured multiple times as this adds its own problems! * The aim here is to enforce that log4j is configured once and only once with * typical but useful features. * * @author Michael Erskine (msemtd) */ public class LogConfigureCheck { public static void check() { // One indicator of log4j not being configured is the lack of appenders // for the root logger. So... if (!Logger.getRootLogger().getAllAppenders().hasMoreElements()) { // Here we could just use BasicConfigurator.configure() // but the layout is not as useful as it could be - here we do // essentially the same but with a better layout... Logger.getRootLogger().addAppender( new ConsoleAppender(new PatternLayout( %-5p %d{HH:mm:ss.SSS} %c [%t] %m%n))); } } } - 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]
RE: [SPAM (Bayesain Analysis)] - Logger object and change filename - Bayesian Filter detected spam
Loggers do not have file names attached. Probably you mean a FileAppender. Each configured Appender is instantiated as singleton, even if it is attached to more than one Logger. Loggers are identified by a arbitrary String, commonly the FQCN. Therefore you cant clone a Logger which has the same name as the original. Explain more about your needs. Why do you have to clone it? Heri -Original Message- From: Reza Razavipour [mailto:[EMAIL PROTECTED] Sent: Monday, September 08, 2008 5:38 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Logger object and change filename - Bayesian Filter detected spam All, I have a Logger object and I need to create a clone of it and change its filename to a different name. How does one do that? The idea here is that I have initialized a Logger instance from log-4j.xml file. Now I need to create a new one, off of it or clone and change the filename. Every attribute of the new Logger instance should be whatever is in the file, only filename is diifferent. Thanks in advance. Reza - 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]
RE: How to get values from log4j.xml file
Logger.getLogger().getAppender( SERVER_LOG ); -Original Message- From: Reza Razavipour [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 26, 2008 2:30 AM To: Log4J Users List Subject: How to get values from log4j.xml file All, I have a log4j.xml file for my application. I have something like the following in the file: appender name=SERVER_LOG class=org.jboss.logging.appender.DailyRollingFileAppender errorHandler class=org.jboss.logging.util.OnlyOnceErrorHandler/ param name=File value=${jboss.server.home.dir}/log/server.log/ /appender How can I programmatically get the properties for SERVER_LOG appender? Thanks in advance. Reza - 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]
RE: Passing log-time values to the Appender
If your calling class which knows about the involved city runs in a separate thread context (for each city) you can use the MDC construct which is maintained on a per thread basis. Just put your city into MDC somewhere at the thread start when the city is known, and then in the MultifileAppender you ask for this value again (MDC.put() and MDC.get(), it's just a HashMap). If you do not want to work with the not released MultifileAppender you could also use your own RepositorySelector which is also based on the MDC. Look the archive, was discussed a lot. If it is always the same thread which covers different cities you cannot use MDC for distinguishing it. You have to wrap your log message into an own object (with members LogMessage and City) which you supply to the log calls instead of the message (it's formally an object and not a string). Additionally you have to provide a custom renderer for this wrapper class which returns the embedded Message member. Heri -Original Message- From: Bruno Melloni [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 11:43 PM To: Log4J Users List Subject: RE: Passing log-time values to the Appender This looks very promising, whether I use it as is or as the basis to customize my appender further. Thank you. I am still not clear as to how to submit the variables in the application (about the time I call Logger.info()) so that they arrive at the Appender's subAppend() method inside the LoggingEvent. Could you clarify? I hope it is not a dumb question. bruno -Original Message- From: Curt Arnold [mailto:[EMAIL PROTECTED] Sent: Friday, August 15, 2008 3:39 PM To: Log4J Users List Subject: Re: Passing log-time values to the Appender On Aug 15, 2008, at 3:19 PM, Bruno Melloni wrote: I have an app that makes all Logger calls happen from a single class and it uses a custom appender. I need to modify the appender so that it splits the logging to separate logs for each city. The city code is available in the calling class and is also being prefixed as the first 3 characters of every message. I know I could create an appender for each city... but that would be insane since there are too many cities. I suspect that the cleanest way would be to 'somehow' pass the city as a parameter when calling logger.info() and 'somehow' customize the appender so that it can read the value and select which file to add it to. Is this possible with log4j? If so, how? Or, is there a better way to separate the logs? Thanks, bruno There has been intermittent activity on a MultiFileAppender which supports multiple open files by one appender. It is not released and is subject to substantial change, but you may want to look at it. See https://issues.apache.org/bugzilla/show_bug.cgi?id=45165 and search the mailing list archives for MultiFileAppender. The source is available in the SVN at http://svn.apache.org/repos/asf/logging/sandbox/log4j/multifile . - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Syslog message is sent twice in the case no log4j configuration file is used
My only guess is that setting the additivity flag by code does not have any effect. Or maybe a kind of activateOptions() on the logger must be performed. Why dont you fetch the RootLogger for appending your syslog appender, as you do in your config example? After the log call you clear the appenders anyway. Heri -Original Message- From: Berwanger, Christian [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 09, 2008 9:27 AM To: Log4J Users List Subject: RE: Syslog message is sent twice in the case no log4j configuration file is used Nobody has an idea? -Original Message- From: Berwanger, Christian [mailto:[EMAIL PROTECTED] Sent: Dienstag, 8. Juli 2008 12:15 To: log4j-user@logging.apache.org Subject: Syslog message is sent twice in the case no log4j configuration file is used Hi log4j comunity, I'm using the log4j appender in order to send my log message to a remote host. I decided not to use the config file because the application itself is already using a central config file which I want to use to read my configurable data (like hostname, port...). However when I'm using the log4j API without config file the message is sent twice times. I read and tried already the hints on the tutorial sites without success which threads several ideas for the problem of multiple same messages. m_logger = Logger.getLogger(SecurityEvent.class.getName()); m_logger.setAdditivity(false); m_syslogAppender = new SyslogAppender(); m_syslogAppender.activateOptions(); m_syslogAppender.setLayout(new PatternLayout(%c: %m%n)); m_syslogAppender.setSyslogHost(localhost); m_logger.addAppender(m_syslogAppender); m_syslogAppender.setFacility(mapFacilityID(this.m_facility)); sendLogMessage(logMessage); m_logger.removeAllAppenders(); However when I tried following configuration file instead it worked fine. # Set root logger level to DEBUG and its only appender to A1. log4j.rootLogger=DEBUG, A1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.net.SyslogAppender # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.SyslogHost=localhost log4j.appender.A1.layout.ConversionPattern=%c: %m%n How can I get only ONE log message? Thanks for all help Christian This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. - 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]
RE: additivity attribute does not work for user-defined logger but works for root logger.
Now things getting clearer. Log4j maintains a logger hierarchy which is determined by the dot withing the logger names, similar to the package hierarchy in java.Example: Config: you declare a logger foo.bar and a root logger, both have one (the same) appender attached. Code: class foo.bar.XY instantiates the logger foo.bar.XY and issues a log call to it. - Log4j will look for a logger foo.bar.XY which is not declared. After that it climbs up the hierarchy path. Thus it looks for logger foo.bar which is found. The appenders of this logger will be served. Now the additivity flag comes into play. If it is set to true (the default), log4j will go on searching the next higher logger in hierarchy foo. No logger will be found. At the end it reaches the root logger and serves the appenders of the root logger. If the additivity flag of foo.bar would be set to false, log4j would stop looking further up for more loggers. With additivity=true you will end up to have the same log statement twice in your appender, with additivity=false only the appenders of the logger foo.bar were served. Heri -Original Message- From: Camer38 [mailto:[EMAIL PROTECTED] Sent: Thursday, July 03, 2008 6:22 PM To: log4j-user@logging.apache.org Subject: Re: additivity attribute does not work for user-defined logger but works for root logger. Thanks for your answer and your time. Why the root logger defined: root level value=debug/ appender-ref ref=taskRedirection/ appender-ref ref=addQuestionSequenceOrder/ /root knows that all the logs from ALL the classes should go the the file specified by appenders:taskRedirection, addQuestionSequenceOrder and a logger: logger name=curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter additivity=true level value=debug/ appender-ref ref=addQuestionSequenceOrder/ /logger knows that ONLY logs from that class curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter has to be served? Is no't realy any way to duplcate the work of the root logger in logger specified by the name curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter? If not, why this parameter additivity=true is present at all? It does nothing. MR. Thorbjørn Ravn Andersen wrote: Camer38 skrev den 03-07-2008 15:25: My assumption was that if I run one of the class curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter I would got all the logs from that class and all the classes used internally by curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter in the addQuestionSequenceOrderTool.log. No. The logger frameworks do not do magic to deduce where logging should go. If you want for classes called to use a specific logger, you must pass it as an argument like all values you want to use. Instead I got an log4j warning: log4j:WARN No appenders could be found for logger (curam.tools.upgradehelper.util.SQLStatements). You are most likely using a logger variable in SQLStatements which has been defined at the top of that class referring to SQLStatments.class. This does not allow log4j to distinguish between the two cases you have. I have the same problem in a project where it is two threads logging in the same file. I have not yet found a good solution. During my testing I have defined a root logger as well, but it does not do what I want. All the expected lines are present in both files but the files are populated with the log from the same class. root level value=info/ appender-ref ref=taskRedirection/ appender-ref ref=addQuestionSequenceOrder/ /root This say that you want all messages at info level or higher to go to both the taskRedirection appender AND the addQuestionSequenceOrder appender. -- Thorbjørn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/%22additivity%22-attribute-does-not-work -for-user-defined-logger-but-works-for-root-logger.-tp18259092 p18263109.html Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: additivity attribute does not work for user-defined logger but works for root logger.
Questions see inline. Heri -Original Message- From: Camer38 [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2008 3:24 PM To: log4j-user@logging.apache.org Subject: RE: additivity attribute does not work for user-defined logger but works for root logger. But in my case I hit slightly different problem. The class foo.bar.XY calls lets say test.bulk.ZY and the class com.create.CR calls test.bulk.ZY as well. Do this two classes (foo.bar.XY and com.create.CR) run in different threads? Or is it the same thread? - Influences possible solutions! I need two full log files for foo.bar.XY and test.bulk.ZY with all the logs information from test.bulk.ZY. Does not make any sense for me. Is it a typo? (test.bulk.ZY in first line should be com.create.CR?). If so, then next question: Do you want the logs of test.bulk.ZY which were called by foo.bar.XY in the log file of foo.bar and the logs of test.bulk.ZY which were called by com.create.CR in the log file of com.create.CR? Otherwise you have to explain more detailled which log calls you want to appear in which appender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: additivity attribute does not work for user-defined logger but works for root logger.
OK, in the following I denote foo.bar.XY as AppA and com.create.CR as AppB and the test.bulk.ZY as UtilityC. Possible solutions: 1. If the UtilityC is instantiated separatly by AppA and AppB (two instances) you are perfectly done by configuring each instance with the desired logger: Config: appender A appender B Logger AppA with appender A Logger AppB with appender B Logger AppA.UtilityC with appender A Logger AppB.UtilityC with appender B Code: Use the suggestion of jake Kjome from today morning. The constructor of SQLStatements wich receives the classname of the calling class must then expand the logger name: receivedClassName + . + this.getClass.getSimpleName(). With this logger name you retrieve the logger from the repository. If AppA had called the constructor, you get the Logger AppA.UtilityC, and so on. 2. Supply the desired logger on each call to the UtilityC class: public static void UtilityC.doSomething( Logger aLoggerToUse ); {...} Drawback: The location info in the log statements would be the location of the call to doSomething(). You can avoid this by using in the UtilityC the generic call of Logger log(): aLoggerToUse.log ( this.getClass.getName(), Level.DEBUG, logMsg, aThrowable ) 3. Since the AppA and AppB run in different threads you could use a MDC value within UtilityC in order to distinguish the loggers. Maybe in combination with a own Repository-Selector which relies on the actual values in MDC. Search the archive, this was discussed a lot, and I supplied whole examples. I hope you got the hint in which direction you should think. Otherwise ask again. Heri -Original Message- From: Camer38 [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2008 5:23 PM To: log4j-user@logging.apache.org Subject: RE: additivity attribute does not work for user-defined logger but works for root logger. Yes, it is a typo. Should be: I need two full log files for foo.bar.XY and com.create.CR with all the logs information from test.bulk.ZY Yes the foo.bar.XY and com.create.CR are run in different threads. I want two logs files - one for foo.bar.XY and the second one for com.create.CR. All of them should have all the calls made in test.bulk.ZY (treat it as utility class) Do you want the logs of test.bulk.ZY which were called by foo.bar.XY in the log file of foo.bar.XY and the logs of test.bulk.ZY which were called by com.create.CR in the log file of com.create.CR? Yes. the foo.bar.XY and com.create.CR has some logging messages as well that needs to go to the right log file. Thanks for helping me with it. M. Bender Heri wrote: Questions see inline. Heri -Original Message- From: Camer38 [mailto:[EMAIL PROTECTED] Sent: Monday, July 07, 2008 3:24 PM To: log4j-user@logging.apache.org Subject: RE: additivity attribute does not work for user-defined logger but works for root logger. But in my case I hit slightly different problem. The class foo.bar.XY calls lets say test.bulk.ZY and the class com.create.CR calls test.bulk.ZY as well. Do this two classes (foo.bar.XY and com.create.CR) run in different threads? Or is it the same thread? - Influences possible solutions! I need two full log files for foo.bar.XY and test.bulk.ZY with all the logs information from test.bulk.ZY. Does not make any sense for me. Is it a typo? (test.bulk.ZY in first line should be com.create.CR?). If so, then next question: Do you want the logs of test.bulk.ZY which were called by foo.bar.XY in the log file of foo.bar and the logs of test.bulk.ZY which were called by com.create.CR in the log file of com.create.CR? Otherwise you have to explain more detailled which log calls you want to appear in which appender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/%22additivity%22-attribute-does-not-work -for-user-defined-logger-but-works-for-root-logger.-tp18259092 p18319243.html Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: additivity attribute does not work for user-defined logger but works for root logger.
Please provide your full log4j.xml. Heri -Original Message- From: Camer38 [mailto:[EMAIL PROTECTED] Sent: Thursday, July 03, 2008 3:26 PM To: log4j-user@logging.apache.org Subject: additivity attribute does not work for user-defined logger but works for root logger. I have two Java classes that used log4j. curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter and curam.tools.upgradehelper.taskredirection.TaskRedirectionConverter Both classes from above uses different class: curam.tools.upgradehelper.util.SQLStatements where a logger in each of the class with defined in following pattern: private static final Logger log = Logger.getLogger(NameOfTheClass.class); Next I have defined log4j.xml. I want to have a full log file in two separate files for both classes. curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter in QuestionSequenceOrderConverterTool.log curam.tools.upgradehelper.taskredirection.TaskRedirectionConve rter in TaskRedirectionConverterTool.log I did a following: I have not defined root at all. My assumption was that if I run one of the class curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter I would got all the logs from that class and all the classes used internally by curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter in the addQuestionSequenceOrderTool.log. Instead I got an log4j warning: log4j:WARN No appenders could be found for logger (curam.tools.upgradehelper.util.SQLStatements). What is the meaning of the attribute additivity for each logger? Why don't I get all the logs in one file? During my testing I have defined a root logger as well, but it does not do what I want. All the expected lines are present in both files but the files are populated with the log from the same class. root level value=info/ appender-ref ref=taskRedirection/ appender-ref ref=addQuestionSequenceOrder/ /root I use log4j-1.2.15.jar Could anybody help me with defining a correct log4j.xml file? -- View this message in context: http://www.nabble.com/%22additivity%22-attribute-does-not-work -for-user-defined-logger-but-works-for-root-logger.-tp18259092 p18259092.html Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: Recommended way of getting a logger
There might be a problem if you use your own RepositorySelector wich maintains different Repositories depending on some context (MDC etc.). Utility classes whose methods can run in different contexts should fetch the logger each time where it is used. Heri -Original Message- From: Jiri Pejchal [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2008 5:57 PM To: log4j-user@logging.apache.org Subject: [SPAM (DNS Blacklist)] - Recommended way of getting a logger - Sending mail server found on relays.ordb.org Hi, is there any real difference between getting logger each time a message is being logged by calling Logger.getLogger() : Logger.getLogger(getClass()).info(message); and putting logger as a class member: final Logger logger = Logger.getLogger(getClass()); and than in methods use: logger.info(message); I have an older web application that uses the first form and I'm just wondering if I could use the second form without consequences. Thanks. Jiri Pejchal - 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]
RE: what to log
I do not agree to yours Logs are not for debugging. In heavy loaded multithreaded applications it could be the only way to debug. The DEBUG level IS definitively for debugging purpose. In production, I agree, the level should be INFO or higher. Heri -Original Message- From: Julius Davies [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2008 8:18 PM To: Log4J Users List Subject: [SPAM (DNS Blacklist)] - what to log - Sending mail server found on relays.ordb.org Richard J. Barbalace wrote the following in the best practises thread: --- [...] Do NOT log valuable information. By valuable, I mean information that has value to the organization or the users, as opposed to the developers. For instance, in medical applications, you should not log personal health information (PHI). This is hopefully obvious, but I would never want to see this in a log: 2004-09-28/18:37:35.138/PDT - Submitted POSITIVE result for HERPES test for patient SMITH. That could violate the HIPAA law, create a severe privacy breach if someone unauthorized reviewed your log, and might include information that the developer is not even legally permitted to see. As another example, in a banking system, you should not log personal account details, social security numbers, etc. to a file whose only purpose is for debugging. Thankfully, in most cases, the exact personal details are not necessary for debugging an application. --- Logs are not for debugging. That's the least important side of logging. (Unfortunately in the java world, debugging is where most of the logs are focused!) I think of logs as an intense write-always, read-rarely database. So I log 5TB of data over a year because my client might need to look at 1KB when something serious happens. As for what to log, look at the real life situation: - The doctor can see the patient's chart (same for doctor's staff). - The lab technician can see the lab's correspondence with the doctor (same for lab's staff). - Additional people probably have access to the information through the lab's software systems, and the doctor's software systems. I don't see why the log shouldn't be able to store similar information. Of course access to the log should be controlled. When I worked at a credit union, the production logs were tightly controlled. Only a few select people had access to specific logs, and developers, almost always, never had access. Probably logs should have the same security, privacy, and access controls around them that one would apply to the database (and its hard-drive). In the end it's just information on a hard-drive. If we go down the path you're suggesting, one should also not store this information in a database! On the other hand, I strongly believe in not logging valuable information when there is no need to log it. Logging a customer's bank balance is never useful. But logging the fact they made a bill payment for $5,000 can be useful if they call up later after something goes wrong. In other words, log important state changes, but don't log the state. If a patient's state changed from healthy to herpes, I would log that. (What if the computer made a mistake? The log will help!) You also can't log information if you promise your customers you will never retain it (or even see it), like a password. Logs are not for developers. Like the rest of the application, they are written by developers, and used by everyone else. In the case of logs the users are usually: sysadmins, customer support, security auditors, lawyers, and occasionally the police! -- yours, Julius Davies 250-592-2284 (Home) 250-893-4579 (Mobile) http://juliusdavies.ca/ - 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]
RE: Unable to display caller name in log info
The FQCN is used for determinating the class which issued the log call. The log framework produces a callstack and searches backwards until it has found the supplied FQCN. The next entry is then taken for expanding the %C pattern in the layout. Normally, if you use the myLogger.debug() (et al.) methods, the Logger class inserts its own FQCN on calling the generic method. That's why the calling class will show up in the rendered log message. Make use of the generic method log() only if you use a centralized log wrapper class. Then you would supply the FQCN of that wrapper class in order to render the name of the class which has called the wrapper. Your example supplies a file name as FQCN. This string cannot be found within the stack trace, so the routine climbs up until the main method of the main class. Nothing found - ?. If you want to see LogTest as %C replacement, you have to supply LogText.getClass().getName() as FQCN. Heri -Original Message- From: Debarshi Sanyal [mailto:[EMAIL PROTECTED] Sent: Monday, June 16, 2008 8:42 AM To: log4j-user@logging.apache.org Subject: [SPAM (DNS Blacklist)] - Unable to display caller name in log info - Sending mail server found on list.dsbl.org Hi, I wrote a small Java program to configure an org.apache.log4j.Logger and log messages using it. Excerpts from the Java file are: package MyPackage; //... public class LogTest { private static Hashtable cLoggerHash = new Hashtable(); private void setLogInfo() { String sLogFile = TestLogFile.log; Logger cLogger = Logger.getLogger( sLogFile ); cLogger.setLevel( Level.toLevel(DEBUG) ); PatternLayout cLayout = new PatternLayout(); cLayout.setConversionPattern( [%d{/MM/dd HH:mm:ss.SSS}]%C - %m%n ); RollingFileAppender cFileAppender = new RollingFileAppender(); //... cFileAppender.activateOptions( ); cFileAppender.setLayout( cLayout ); cLogger.addAppender( cFileAppender ); cLoggerHash.put( sLogFile, cLogger ); } public static void main (String[] args) { LogTest logTest = new LogTest(); logTest.setLogInfo(); Logger cLogger = Logger.getLogger( TestLogFile.log ); cLogger.log(TestLogFile.log, Level.INFO, \t ++ This is a test log + , null); } The output is: [2008/06/13 20:24:53.415]? - ++ This is a test log + The fully qualified classname is NOT displayed. Instead a ? is displayed. Please help. Regards, Debarshi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JDBCAppender
Have you attached the appender to any logger? Heri -Original Message- From: Simonebernardi [mailto:[EMAIL PROTECTED] Sent: Thursday, May 08, 2008 12:12 PM To: log4j-user@logging.apache.org Subject: [SPAM (DNS Blacklist)] - JDBCAppender - Sending mail server found on list.dsbl.org Hi all, I have a problem with JDBCAppender. I wrote a configuration file, but the table does not write anything and not give me any errors. why? appender name=JDBC class=org.apache.log4j.jdbc.JDBCAppender param name=url value=jdbc:mysql://localhost:3306/sicve_uel1/ param name=dbclass value=com.mysql.jdbc.Driver/ param name=username value=sicve/ param name=password value=sicve/ param name=sql value=INSERT INTO logtest (id, prio, cat, thread, msg, layout_msg, throwable, ndc, mdc, mdc2, info, addon, the_date, the_time, the_timestamp, created_by) VALUES (@INC@, '@PRIO@', '@CAT@', '@THREAD@', '@MSG@', '@LAYOUT:1@', '@THROWABLE@', '@NDC@', '@MDC:MyMDC@', '@MDC:MyMDC2@', 'info timestamp: @TIMESTAMP@', 'addon', cast ('@LAYOUT:3@' as date), cast ('@LAYOUT:4@' as time), cast ('@LAYOUT:3@ @LAYOUT:4@' as timestamp), 'me')/ param name=buffer value=1/ param name=commit value=true/ param name=quoteReplace value=true/ param name=throwableMaxChars value=3000/ param name=layoutPartsDelimiter value=#-#/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=[%t] %m#-##-#%d{dd.MM.}#-#%d{HH:mm:ss}/ /layout /appender Thank you - 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]
RE: - Setting logging levels
If the string which you supply to logger.info() must first be constructed (normally a expensive operation which you dont want to do if info is not enabled) you can avoid this by: if ( logger.isInfoEnabled() ) { logger.info( prepareString( args ) ); } Without this surrounding if the string would be constructed anyway only in order that the log frameworks throws it away if the desired level is not enabled. The isXXXEnabled() exists for each level. Heri -Original Message- From: lp_1431 [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 06, 2008 3:02 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - Setting logging levels - Bayesian Filter detected spam I m new to log4j. Is the logging level put in the properties file is a default logging level that is set? How is that logging level accessed when we write... logger.info(Info message); in the main program. Please let me know about this. THANKS -- View this message in context: http://www.nabble.com/Setting-logging-levels-tp17082241p17082241.html Sent from the Log4j - Users mailing list archive at Nabble.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]
Re: Different Loggers for Different Instances of Same Class
Hi The problem of different log files within the same app does not arise on the main classes of each job (this can be configured very easy through different appenders), but in all underlying framework and helper classes. If the log outputs of these underlying classes should be separated too, then the RepositorySelector is a good choice, and the selector criteria can be defined via MDC. I did this in a similar project (a scheduler starts different jobs at given time intervals, each job has its own log file, but all self written without any big framework). To achieve this you have to ensure the following: - each job must be executed in an own fresh Thread (to enable the selection criteria through MDC) - classes which are common to different jobs must not have static Logger instances but instance member loggers (assuming the class is newly instantiated on a new job) - utility classes with static helper methods must neither have static nor class member Logger instances but have to fetch the correct Logger within each call of each method - on start of each job (Thread) you have to put a distinct value into MDC (i.e. JobName=JobA), before any logger is fetched from the repository - The RepositorySelector maintains a Repository for each JobName. When it is asked for the correct repository the Selector will fetch the actual job name from MDC. - Somewhere the file appender(s) for the different files must be supplied with the desired file name. This can be done at the same code location where the job starts and the MDC is updated. Iterate over the found appenders and change the file name. I posted this solution some times ago (~2-3 years) to this news group. There was even a second selector criteria beside the actual job: each job was done on different mandators, so we had to log into different files for each job/mandator pair. Both criterias were in the MDC, the RepositorySelector maintained a Respository for each such pair. If you dont find my posting write me and I will send you the solution. Heri -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED] Sent: Monday, April 07, 2008 7:42 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Re: Different Loggers for Different Instances of Same Class - Bayesian Filter detected spam So, because you use Spring setter injection, you think you can't name your loggers in a custom way? Why not use a combination of constructor and setter injection? I'm not sure why you'd need a repository selector in this case anyway? What would be the selection criteria? Are you thinking thread? While that is possible, it seems both heavyweight and unnecesary. It doesn't take multiple logger repositories to get differently named logger output into separate files. In Spring, just use... constructor-arg type=java.lang.String value=InstanceNameQualifierValue/ OR constructor-arg index=0 value=InstanceNameQualifierValue/ OR (if it's the only constructor argument) constructor-arg value=InstanceNameQualifierValue/ Now, you mentioned MDC, and that's a separate, and seemingly unrelated, issue. What problems are you having with MDC? If I'm missing something, please let me know. Jake On Mon, 07 Apr 2008 08:24:25 -0400 Robert Pepersack [EMAIL PROTECTED] wrote: Hi Jake, Thanks for your response. I did some reading from my copy of The complete log4j manual. Chapter 8 has a solution to this problem: create a RepositorySelector. But, for me this is only a partial solution. This is because I'm using the Spring Framework's IOC container to manage my application (which is a Java job scheduler that uses Quartz). This means that, when I first start my application, the IOC container creates most of the instances of my classes (including my Quartz jobs), and uses setter injection to create the state for my classes. I don't know how to get my loggers, and associate them with the current thread using the MDC, when they have already been created by the Spring IOC container. Do you know how? Thanks, Robert Pepersack Senior Lead Developer Maryland Insurance Administration 410-468-2054 Jacob Kjome [EMAIL PROTECTED] 04/06/2008 4:42 PM You can use per-instance loggers and name you loggers as... private Logger logger; JdbcFacade(String instanceNameQualifier) { this.logger = this.getClass().getName() + istanceNameQualifier; } instanceNameQualifier might be A or B or whether else you want it to be. Jake Robert Pepersack wrote: Hello. Thanks in advance for your help. I'm running scheduled jobs, and they create their own instances of my JDBC class. For example, JobA creates a new JdbcFacadeA, and JobB creates its own JdbcFacadeB. I would like to log each job in its own log (easy). But, I want the output from JdbcFacadeA to go to the
RE: conditional logging of exception
I dont really understand your thoughts why an error should not be logged along with stack trace, since it is an exceptional situation which should not occur often. Errors in logs are never noise ratio. But your problem with classname, linenummer etc. can be solved if you use the overloaded log method which takes as first parameter the FQCN. FQCN is then the one of the calling class. Your static method: public static void logVerboseOnLevel( Object instance, Logger logger, Level thresholdLevel, Exception e, Level logAtLevel) { if (logger.isEnabledFor(thresholdLevel)) { logger.log( instance.getClass.getName(), logAtLevel, e, e); } else { logger.log( instance.getClass.getName(), logAtLevel, e); } } and called like: Logger logger = Logger.getLogger(getClass); Wrapper.logVerboseOnLevel( this, logger, Level.DEBUG, new Exception(), Level.ERROR); NOT TESTED, just hacked in by mind. Heri -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2008 8:07 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - conditional logging of exception - Bayesian Filter detected spam Hello, For a webapp, it would be nice to be able to conditionally log stack trace along with exception. Scenario: (1) Production application ships with Level set to Level.ERROR. (2) An app admin notices some errors in the log [Logger.error(Object)]. (3) A means is available [Logger.setLevel()] to dynamically set Level to Level.DEBUG for a particular class. (4) When the error occurs again, the stack trace is logged along with the error [Logger.error(Object, Throwable)]. A solution would be to have a wrapper class with a static method like: public static void logVerboseOnLevel(Logger logger, Level thresholdLevel, Exception e, Level logAtLevel) { if (logger.isEnabledFor(thresholdLevel)) { logger.log(logAtLevel, e, e); } else { logger.log(logAtLevel, e); } } and called like: Logger logger = Logger.getLogger(getClass); Wrapper.logVerboseOnLevel(logger, Level.DEBUG, new Exception(), Level.ERROR); If logger level is ERROR, just the one liner is logged. If logger level is DEBUG, the stack trace is logged. The benefit is to minimize the amount of information in the log file, unless the cause of the exception is being sought. Since it is possible to set log level per class, the signal to noise ratio is much more conducive to finding the problem. In log4j.properties, the appender is defined like: log4j.appender.MY_APPENDER.layout.ConversionPattern=%d [%t] %-5p %c:%l %C:%-4L - %m%n The portion %C:%-4L means I want the class and line number where the problem occurred. This conflicts with the wrapper, as its class and line number are the ones used to invoke log4j. Also, it would be nice to only use the wrapper class in specialized situations. So any solution would need to handle both the straightforward Logger use case, as well as the wrapper. There is an old post on this forum describing a similar problem, but I couldn't really figure out how to utilize the responses. http://mail-archives.apache.org/mod_mbox/logging-log4j-user/20 0710.mbox/[EMAIL PROTECTED] Originally I had the chunk of code above copied in each specialized place where I needed it, then I refactored the copies into a utility class, and ran into the logging output issue. Any suggestions for a solution to this usage case? Thanks... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Could not find root logger information Is this OK?
I am not quite shure about property configuration (I work always with xml). But I suspect that the double configuration of the root logger (rootLogger and rootCategory) causes your problem. But the both lines rootLogger and rootCategory means the same. The use of the term Category is deprecated and replaced by the term Logger. Heri -Original Message- From: Mustafa Cayci [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 10:51 AM To: log4j-user@logging.apache.org Subject: Could not find root logger information Is this OK? Hello, I have configured log4j in my application server. I have defined the following log4j.properties log4j.debug=true log4j.threshold=ALL log4j.rootLogger=DEBUG,fileAppend log4j.rootCategory=DEBUG,fileAppend log4j.logger.com.businessobjects.security.jaas=DEBUG log4j.logger.org.apache=ERROR log4j.appender.conAppend=org.apache.log4j.ConsoleAppender #log4j.appender.conAppend.Threshold=INFO log4j.appender.conAppend.layout=org.apache.log4j.PatternLayout log4j.appender.conAppend.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n log4j.appender.fileAppend=org.apache.log4j.RollingFileAppender log4j.appender.fileAppend.Threshold=DEBUG log4j.appender.fileAppend.File=jsr168app.log log4j.appender.fileAppend.MaxFileSize=5MB log4j.appender.fileAppend.MaxBackupIndex=100 log4j.appender.fileAppend.Append=true log4j.appender.fileAppend.layout=org.apache.log4j.PatternLayout log4j.appender.fileAppend.layout.ConversionPattern=%d %-5p [%t] %-17c{2} - %m\r\n When I start my application server, I am seeing the following messages ... 08/03/19 04:33:55 log4j: Finished configuring. 08/03/19 04:33:55 log4j: Reading configuration from URL classloader:/META-INF/CrystalEnterprise.Trace/basic.properties 08/03/19 04:33:55 log4j: Could not find root logger information. Is this OK? 08/03/19 04:33:55 log4j: Parsing for [com.businessobjects.sdk] with value=[ERROR, CE1]. 08/03/19 04:33:55 log4j: Level token is [ERROR]. 08/03/19 04:33:55 log4j: Category com.businessobjects.sdk set to ERROR 08/03/19 04:33:55 log4j: Parsing appender named CE1. ... I am also seeing Could not find root logger information. Shouldn't log4j.rootLogger=DEBUG,fileAppend do the trick? Thanks, Mustafa __ __ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ - 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]
RE: How can I set the output color of log4j?
Since you do not specify which displaying application shall show colors I can give you advice how to achieve it within the eclipse console display: Configure two separate appenders. One for the levels WARN and higher and one for the levels INFO and lower. Assign them to the std.err and std.out. Here a config example: appender name=CONSOLE.ERR class=org.apache.log4j.ConsoleAppender param name=target value=System.err/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p [%-7t] %F:%L %x - %m%n/ /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=warn/ param name=LevelMax value=fatal/ param name=AcceptOnMatch value=false/ /filter /appender appender name=CONSOLE.OUT class=org.apache.log4j.ConsoleAppender param name=target value=System.out/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p [%-7t] %F:%L %x - %m%n/ /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=debug/ param name=LevelMax value=info/ param name=AcceptOnMatch value=false/ /filter /appender Eclipse console will display WARN and higher in red, INFO and lower in black color. Heri -Original Message- From: youhaodeyi [mailto:[EMAIL PROTECTED] Sent: Saturday, March 15, 2008 9:50 AM To: log4j-user@logging.apache.org Subject: How can I set the output color of log4j? I want to set different colors for different priority log. How can I do that? -- View this message in context: http://www.nabble.com/How-can-I-set-the-output-color-of-log4j- -tp16065799p16065799.html Sent from the Log4j - Users mailing list archive at Nabble.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]
Re: How to log binary data
I for myself do such things when preparing the log message, i.e.: if (myLog.isDebugEnabled()) { myLog.debug( received binary data:\n + Conversions.byteArrayToHexDump( myByteArray ) ); } Annother apporach is to write your own renderer. In this case you would have also to define an own class which transports the message and binary data through the log4j layers until it reaches your renderer. Configuration: renderer renderedClass=my.company.com.BinaryWrapper renderingClass=my.company.com.BinaryRenderer/ Code: if (myLog.isDebugEnabled()) { BinaryWrapper wrap = new BinaryWrapper( received binary data, myByteArray ); myLog.debug( wrap ); } When log4j is about to convert the supplied Object to String, it will call your BinaryRenderer supplying your BinaryWrapper instance. Remember: the formal parameter of Logger.debug etc. is an Object and not a String. If no renderer for a particular class is configured, log4j just calls toString() of the supplied Object otherwise it calls the configured renderer. Heri -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of teknokrat Sent: Monday, March 17, 2008 2:06 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - How to log binary data - Bayesian Filter detected spam I have a requirement to log raw binary data. This will be mostly ASCII characters but will contain non-displayable control characters such as \0, etc. My first thought was to write an appender by extending the FileAppender class but I cannot see how to do this as I need access to an OutputStream and not a Writer. Does anyone have any good ideas of how this can be done witht he minimum of fuss in log4j? cheers - 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]
RE: Log level problems
Adding the additivity attribute should do the trick: category name=org.jboss.ejb.plugins.cmp additivity=false BTW: the name category is deprecated. Use logger instead. Your cited configuration does not declare the referenced appender FILE. Heri -Original Message- From: Adrian Mitev [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 26, 2008 11:37 AM To: log4j-user@logging.apache.org Subject: Log level problems Hi all! I want to display in the console only INFO messages but for one log level to display the DEBUG messages. Here is my log4j.xml appender name=CONSOLE class=org.apache.log4j.ConsoleAppender errorHandler class=org.jboss.logging.util.OnlyOnceErrorHandler/ param name=Target value=System.out/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{dd-MM- HH:mm:ss,SSS} %-5p [%c{1}] %m%n/ /layout /appender category name=org.jboss.ejb.plugins.cmp priority value=DEBUG / appender-ref ref=CONSOLE/ /category root level value=INFO/ appender-ref ref=CONSOLE/ appender-ref ref=FILE/ /root I want to log the DEBUG messages for org.jboss.ejb.plugins.cmp only. How should i do this? -- Regards Adrian Mitev - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
reasonable config for spring and hibernate
Hi all In my actual project I work the first time with spring and hibernate. Configuring only a root logger on debug level overwhelms the log with messages from these frameworks. Even on INFO level there still are a lot of messages. I dont want to switch off the loggings from these frameworks during developement because I want to know how hibernate works. I want log entries to see: - when a transaction starts - when a transaction gets committed or rollbacked - when entities are retrieved from the underlying DB or when they are retrieved from a internal cache - when entieties are updated, preferably with the values of the entity Has someone of you hibernate cracks a sample log4j.xml which achieves these needs without flooding the log? Tks Heri Bender - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [SPAM (Bayesain Analysis)] - Newbie help: Capturing Stdout and Stderr into log4j - Bayesian Filter detected spam
Log4j is not designed for hooking any system event. It's mainly a very flexible output channel. Capturing the stdout: Assign your own OutputStream to System.out and you get all messages to stdout. These you can write then to any logger you wish. Exceptions are catched in the normal java way through try..catch. Within the catch block you would typically write myLog.error( Exception catched in method XY, e ); Heri -Original Message- From: enthucoder [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 28, 2007 11:46 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - Newbie help: Capturing Stdout and Stderr into log4j - Bayesian Filter detected spam Hi, I am relatively new to log4j. Can anybody help me guiding towards the best practice to achieve following? 1.) How would i capture the Std out messages into log4j? (or is it anything different than just embedding messages one wants to print into logger() method?) 2.) Also there would be some exceptions or errors (would be the right term I guess) which are unexpected like NullPointerException etc, which usually leaked. How would one go about capturing these? Thanks in advance. .H -- View this message in context: http://www.nabble.com/Newbie-help%3A-Capturing-Stdout-and-Stde rr-into-log4j-tf4893246.html#a14013050 Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: Advantages of using static log methods vs sub classes methods
I would use wrappers, if at all, only for app or module wide special loggers (like fatal error alerting etc.), and only - if there is a special need to do something with the log event which cannot be done using the log4j framework - if some special initializing of the involved appenders is needed which cannot be done through configuration. For debugging purpose I would recommend to use it the usual way (each class has its private logger instance which is named after the fully qualified classname). Advantages: - you keep the main benefit of log4j to finetune your log output depending on classes or packages per configuration without changing code. - you can reuse some basic classes in other apps without to have carry over your log wrapper. Applies also to unit testing which can be done without the need of initializing the wrapper framework. Disadvantages of wrapper: - wrapper instances have to be carried all along the callstack or must be accessible in a static way. - Danger of unwanted dependencies (also circular) grows. Heri -Original Message- From: Integrator [mailto:[EMAIL PROTECTED] Sent: Monday, November 12, 2007 8:47 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - Advantages of using static log methods vs sub classes methods - Bayesian Filter detected spam Hi , I am comparing the advantages and disadvantages using log4j at its own vs some sub classes (or wrapper classes) with methods for logging messages from application. Which one is better and why ? So far i could understand Utilization of wrapper ensures that you are not tied to specific logging solutions. Is that it or there is something more ? Please express your views and experience on it. Thanks, Integrator -- View this message in context: http://www.nabble.com/Advantages-of-using-static-log-methods-v s-sub-classes-methods-tf4793407.html#a13712766 Sent from the Log4j - Users mailing list archive at Nabble.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]
Re: FileAppender location question
In eclipse you can set the working dir in the launch configurations second page Arguments. Heri -Original Message- From: mbraunwart [mailto:[EMAIL PROTECTED] Sent: Friday, November 02, 2007 8:07 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - Re: FileAppender location question - Bayesian Filter detected spam I'm sorry, I don't know where I can set this at in the application, or maybe I might not have been clear. The problem that seems to be the case is that, I imported the project into eclipse, but not in my workspace, it stores the logs, without a definite path set, to where eclipse is running from, i.e. C:\eclipse, even though that is not my workspace. So I'm not sure where I need to fix this. James A. N. Stauffer wrote: The relative path should be from the running working directory so change the working directory for each program. On 11/2/07, mbraunwart [EMAIL PROTECTED] wrote: When I started a couple tutorials for Log4J in eclipse, it would store the file inside of the folder i specified in the root of the project folder without having to give it a full path. This current project that I am working with, taking pretty much the same xml and idea from the tutorials, I am having a problem to where it wants to store my logs in the eclipse program folder, as opposed to the project root folder. I have 3 projects set up, one really has nothing to do with the other 2, the main project where i am gathering my logs is a controller core, and the front end is another project that is a j2ee interface which uses the jar from the core project. Right now I have to feed it an exact path name to where I want the logs stored, I'd like to figure out the best way to have it store in a logs/activity.log from the root of the core project. I've tried searching for answers to this but I seem to not either be using the right search criteria, or the answer is out there or I'm overlooking it. I have a feeling it might be a simple answer and I'm overlooking it, but any help would be greatly appreciated. Thank you -- View this message in context: http://www.nabble.com/FileAppender-location-question-tf4738706.html#a13551552 Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- James A. N. Staufferhttp://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ -- View this message in context: http://www.nabble.com/FileAppender-location-question-tf4738706.html#a13554219 Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: appenders with thread id affinity
Hi I also suggest the approach with using MDC and custom filter. You probably want the outputs from each thread in separate files. If so, you have two possibilities: 1. Implementing a own RepositorySelector which holds different repositories for each thread / thread sub group. 2. Creating and configuring the special appender at run time each time such a thread starts. Remove it after thread ends. Approach 1): At Thread start you put the threadID to MDC (is threadlocale) before you make the first call (implicit or explicit) to LogManager. A subsequent call to log4j (i.e. by requesting a particular Appender or a Logger) will end up in your repository selector which can check the MDC value and return a repository specific to this thread. The target of the found appender can then be configured at runtime (i.e. supplying the file name with thread id). This approach does not work in all cases if you have static Loggers in your working classes, since these were instantiated at first class loading. Similar problem with static helper functions. The logger has to be fetched at each entry of such a function. Approach 2): You not only have to create the special appender but also to attach it to loggers. The problem arisis that there may be configured loggers other than root which may have the additivity flag set to false. If you attach the new appender only to root logger, this other configured loggers would never output to the new appender. So you have to loop over all loggers and attach the new appender to all loggers which have the additivity flag set to false. Otherwise you would loose one main benefit of log4j (finetuning log outputs per class). But you definitely loose the possibility of reconfiguring during runtime (configureAndWatch). Heri -Original Message- From: Maarten Bosteels [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 31, 2007 11:03 PM To: Log4J Users List Subject: Re: appenders with thread id affinity I think what you want can easily be done with a cobination of the MDC and a custom filter: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/A ppenderSkeleton.html#addFilter(org.apache.log4j.spi.Filter) 1) When your unit of work starts, you put some key/value in the MDC 2) the custom filter denies all request where the specific key/value is not set 3) when unit of work is done, you remove key from MDC You don't even have to add appender + filter at runtime, you can do it initialization. HTH Maarten On 10/31/07, William Damian Faris [EMAIL PROTECTED] wrote: I was wondering if there is a way to do the following that may or may not be possible. I have a bunch of code that is already using log4j right now. The loggers that are used to log messages are your standard logfactor.getlog ( ClassName.class). I would like to capture all the logging messages for a given unit of work into a new appender that is set up at runtime. I would like all the code that runs after setting up this appender to send log messages to this new appender as well as the pre-existing configured appenders, and I imagine the way to do this is via ThreadId. Something like this 1. Setup a new appender 2. Somehow insert the appender into the log4j configuration tied to the current threadID 3. call a bunch of old code that is already using log4j, all the log messages are caught by the existing configured appenders in addition to my new appender 4. return from calling code 5. Shutdown the new appender and remove it from the existing log4j configuration. So I am asking if its possible to insert an appender such that subsequent log messages for a certain threadID go to that appender, and then remove that appender after code has run. I will be looking at the docs and code for log4j but thought I would ask to see if anyone has done anything like this. Thanks Will
RE: [SPAM (Bayesain Analysis)] - Can i instentiate the log4j logger object? - Bayesian Filter detected spam
Hallo Michael About a year ago it was discussed to have a MultiFileAppender which can cover exactly this problem. The idea did not get over a sandbox project and is now sleeping. Using current version of log4j it is possible if you write your own repository selector. The default repository is also a singleton, but your self written selector can instantiate a repository for each thread. On each thread start you will then configure your appender(s) by code. Look at the archive, this was discussed a lot (a year or two ago). Heri -Original Message- From: Michael [mailto:[EMAIL PROTECTED] Sent: Friday, October 19, 2007 11:13 AM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - Can i instentiate the log4j logger object? - Bayesian Filter detected spam Dear sir, Recently I was try with the log4j to use it to record my system out messages, however it seems that when I want to have 2 thread within the same JVM where each of them having their own log files is not possible. Because the Logger object is singleton. Is there any way that I can have init 2 different instance of Logger (with different configuration of file to be write to) on each thread and each their own log files ?? Thanks, Logo-sig-(tecforte) Sincerely, Michael Liong Software Engineer TecForte Sdn Bhd ‘Smart Security Management’ Parcel No 2A-13-2, Plaza Sentral - Phase II, Jalan Stesen Sentral 5, Kuala Lumpur Sentral, 50470 Kuala Lumpur, Malaysia Tel: +6(03) 2264 3164 Fax: +6(03) 2264 3064 http://www.tecforte.com/ http://www.tecforte.com == This e-mail and any files transmitted with it are confidential, legally privileged and are for the sole use of the intended recipient. If you are not the intended recipient of this e-mail or any part of it, you are not to reproduce or distribute it. Please notify the sender by return e-mail and discard the contents. In circumstances where the contents of this e-mail may have legal significance, you should not place any reliance on its contents without following up in writing. No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.488 / Virus Database: 269.15.1/1078 - Release Date: 10/18/2007 5:47 PM
RE: [SPAM (Bayesain Analysis)] - How to always log the host name? - Bayesian Filter detected spam
Put the hostname somewhere at app start into MDC: MDC.put( hostname, myHostname ); The conversionPattern can resolve MDC values by using the switch %X{ID}. The ID in my example is hostname (without quotes). Heri -Original Message- From: Hans Schwaebli [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 04, 2007 3:56 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - How to always log the host name? - Bayesian Filter detected spam How can I configure the log4j logging to add the hostname information into the logging output? Most naturally would be to find a conversion character for the hostname in the PatternLayout. But there is none. - Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Re: Urgent Please--How to create different log files with different property files in same webapplication
Your Implementation of repository selector is quite useless, because your distinction criteria relies on the current classloader. Log4j's default repository selector does this already for you. It is a singleton within the scope of one distinct classloader. If annother classloader comes onto stage there will be created a new repository selector automatically. So each classloader context has its own separate logger universe which can be configured independently (i.e. each different WEB-INF app in Tomcat has its own classloader). A custom RepositorySelector has it's benefits if you can extract at a given time in code execution a unique criteria . This might differ when the same code is executed again (i.e. might be the user id of the logged in user, or others). How to establish this criteria is very dependent on the architecture of your application and your goal of separating the log outputs. I reviewd your mail-thread and I must admit I don't quite understand the relationship of your two applications abc and xyz. Nor do I understand which log statements you wish to be written to the one log file and which one to the other. If the distinction only relies on the code spot where the log output is generated then the best approach would be to define separate Loggers for your own classes (like james already mentioned), name them by the fully qualified classname and set the additivity flag to false. Like that log outputs issued by the classes of xyz app never reach the appenders of the classes of abc app and vice versa. But be aware: You cannot configure the same LogManager twice and hope the second configuration adds to the first one. The second configuration action will purge the first one before configuring new. But you can create new Loggers and Appenders by code and add them to the first loaded configuration. To give more precise advices you must explain more about the architecture of your applications. Heri -Original Message- From: sivamma [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 26, 2007 12:12 PM To: log4j-user@logging.apache.org Subject: [SPAM (Keyword Checking)] - Re: Urgent Please--How to create different log files with different property files in same webapplication - Found word(s) list error in the Text body Hi I tried to implement the repository selectors.But still problems occurs. Please find my repository selector below. However i am not using Servlets to initialize the log4j. So Even to implement repository selector i am not using servlets. Our customers requested us to not use servlets.Since we made everything using Java and jsps. == package com.CK; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.log4j.Hierarchy; import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.spi.LoggerRepository; import org.apache.log4j.spi.RepositorySelector; import org.apache.log4j.spi.RootCategory; import java.io.File; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PropertyConfigurator; /** * This RepositorySelector is for use with web applications. * It assumes that your log4j.xml file is in the WEB-INF directory. * @author Stan Silvert */ public class Log4jSetup implements RepositorySelector { private static boolean initialized = false; // This object is used for the guard because it doesn't get // recycled when the application is redeployed. private static Object guard = LogManager.getRootLogger(); private static Map repositories = new HashMap(); private static LoggerRepository defaultRepository; /** * Register your web-app with this repository selector. */ public static String rPath = null; public Log4jSetup(String realPath) { rPath = realPath; //ServletConfig config; init(); } public static synchronized void init() { //String realPath = getServletConfig().getServletContext().getRealPath(/); //rPath = realPath; if( !initialized ) // set the global RepositorySelector { defaultRepository = LogManager.getLoggerRepository(); RepositorySelector theSelector = new Log4jSetup(); LogManager.setRepositorySelector(theSelector, guard); initialized = true; } Hierarchy hierarchy = new Hierarchy(new RootCategory(Level.DEBUG)); loadLog4JConfig(hierarchy); ClassLoader loader = Thread.currentThread().getContextClassLoader(); repositories.put(loader, hierarchy); } // load config.properties from WEB-INF private static void loadLog4JConfig(Hierarchy hierarchy) { try { String filePath =
Re: Setting up log4j.xml
Log events which are sent to a specialized Logger (=not Root Logger) will by default climb up the logger hierarchy until the root logger and serve every appender of every logger found on its way. Your example: a log event sent to logger named loggingexample.Main arrieves to this logger, does not find an appender, looks up the next upper logger in hierarchy, finds the root logger with level DEBUG and serves its appender A1. To achieve what you want, supply the logger loggingexample.Main with the appender-ref A1 and set the logger's property additivity=false. This will prevent the log event to climb further up the hierarchy. logger name=loggingexample.Main additivity=false level value=error/ appender-ref ref=A1 / /logger Heri -Original Message- From: chuanjiang lo [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 05, 2006 7:59 AM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Re: Setting up log4j.xml - Bayesian Filter detected spam i'm having this config.. i would like to print out error and fatal msgs in the Main class of loggingexample package, how come it is still printing debug level and above msgs? appreciate any help appender name=A1 class=org.apache.log4j.ConsoleAppender layout class=org.apache.log4j.PatternLayout !-- Print the date in ISO 8601 format -- param name=ConversionPattern value=%d [%t] %-5p %c - %m%n/ /layout /appender logger name=loggingexample.Main level value=error/ /logger root level value=debug/ appender-ref ref=A1 / /root - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Setting up log4j.xml
It shouldn't. Maybe you are not fetching the logger correctly. How you instantiate the logger in the Main class? It should be: Logger.getLogger( loggingexample.Main ) or Logger.getLogger( this.getClass() ) The latter is only valid if loggingexample.Main is exactly the FQCN of MAIN (normally there is a a toplevel domain in front, i.e. com.loggingexample.Main). Try it with annother appender (maybe FileAppender) for the loggingexample.Main-Logger. So you can see which logger outputs the event. Heri -Original Message- From: chuanjiang lo [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 05, 2006 12:30 PM To: Log4J Users List Subject: Re: Setting up log4j.xml On 12/5/06, Bender Heri [EMAIL PROTECTED] wrote: Log events which are sent to a specialized Logger (=not Root Logger) will by default climb up the logger hierarchy until the root logger and serve every appender of every logger found on its way. Your example: a log event sent to logger named loggingexample.Main arrieves to this logger, does not find an appender, looks up the next upper logger in hierarchy, finds the root logger with level DEBUG and serves its appender A1. To achieve what you want, supply the logger loggingexample.Main with the appender-ref A1 and set the logger's property additivity=false. This will prevent the log event to climb further up the hierarchy. logger name=loggingexample.Main additivity=false level value=error/ appender-ref ref=A1 / /logger Heri This is my current xml configuration..somehow the class Main still prints out those levels that are below error. log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=false appender name=A1 class=org.apache.log4j.ConsoleAppender layout class=org.apache.log4j.PatternLayout !-- Print the date in ISO 8601 format -- param name=ConversionPattern value=%d [%t] %-5p %c - %m%n/ /layout /appender logger name=loggingexample.Main additivity=false level value=error/ appender-ref ref=A1/ /logger root level value=debug/ appender-ref ref=A1/ /root /log4j:configuration - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Log4J System alerts
Here a example how to configure filters. Note: Filters are only available if you use xml configuration. appender name=CONSOLE.OUT class=org.apache.log4j.ConsoleAppender param name=target value=System.out/ layout class=org.apache.log4j.PatternLayout param name=ConversionPattern value=%d{HH:mm:ss.SSS} (%6r) %-5p [%-7t] %F:%L %x - %m%n/ /layout filter class=org.apache.log4j.varia.LevelRangeFilter param name=LevelMin value=debug/ param name=LevelMax value=info/ param name=AcceptOnMatch value=false/ /filter filter class=ch.ergonomics.pms.common.supervision.TraceDenyFilter/ filter class=ch.ergonomics.pms.common.supervision.XMLDenyFilter/ /appender This appender has three filters attached. The first is a log4j built in filter (LevelRangeFilter), the thow others are self written filters, derived from org.apache.log4j.spi.Filter which filter LogEvents based on some values in MDC. If a LogEvent reaches an appender, it is presented to the attached filters in the order they are configured. The Filter results in: - ACCEPT the LogEvent is accepted, no more further Filters are asked - DENYthe Log Event is rejected, no more further Filters are asked - NEUTRAL next filter in chain is asked within a self written Filter you can implement any logic you want. Heri -Original Message- From: garima015 [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 11:39 PM To: log4j-user@logging.apache.org Can you please give me some more idea on how to create that filter..and how this will be called - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Log4J System alerts
If you want to work with filters you must use log4j.xml configuration instead of log4j.properties. The properties configuration style does not support filter entries. It's anyway recommended to use xml configuration since: - the auto configuration mechanisme of log4j looks first for the log4j.xml file - the properties configuration style is no more supported in future releases - In my opinion the xml is clearer and more self-documenting than properties TraceDenyFilter and XMLDenyFilter are self made classes derived from the log4jFilter class (see previous mail). They serve only as example how you can configure your own filter. Note that you can also configure own member properties of your own filter if they have standard setter methods: public void setMyProperty( String aValue) will be configured as param name=MyProperty value=HelloWorld/) The storage location of your self made filter is like any other class: somewhere in the known classpath. Heri -Original Message- From: garima015 [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 3:37 PM To: log4j-user@logging.apache.org Subject: Re: Log4J System alerts Thanks Heri for ur help.. one thing more i want to ask is is this configuration will be done in Log4j.properties..if not then where i have to write all this.And is TraceDenyFilter and XMLDenyFilter are self made filters or do i have two build two classes extending these filters. In case so where i have to save these filter classes. ur help is really useful to me - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Log4J System alerts
For auto configuration log4j.xml must be found in the classpath. Else you can do it within code by calling DOMConfigurator.configure( myFullOrRelativeFileName ). Heri -Original Message- From: garima015 [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 4:05 PM To: log4j-user@logging.apache.org Subject: RE: Log4J System alerts Heri one more thing can we place log4j.xml in root directory of project as my project is not a Web project so i wont be having web-inf in that!!! garima015 wrote: Thanks Heri..thanks for ur help!!! I hope log4j.xml will also be read in the same manner as log4j.properties.. Bender Heri wrote: If you want to work with filters you must use log4j.xml configuration instead of log4j.properties. The properties configuration style does not support filter entries. It's anyway recommended to use xml configuration since: - the auto configuration mechanisme of log4j looks first for the log4j.xml file - the properties configuration style is no more supported in future releases - In my opinion the xml is clearer and more self-documenting than properties TraceDenyFilter and XMLDenyFilter are self made classes derived from the log4jFilter class (see previous mail). They serve only as example how you can configure your own filter. Note that you can also configure own member properties of your own filter if they have standard setter methods: public void setMyProperty( String aValue) will be configured as param name=MyProperty value=HelloWorld/) The storage location of your self made filter is like any other class: somewhere in the known classpath. Heri -Original Message- From: garima015 [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 3:37 PM To: log4j-user@logging.apache.org Subject: Re: Log4J System alerts Thanks Heri for ur help.. one thing more i want to ask is is this configuration will be done in Log4j.properties..if not then where i have to write all this.And is TraceDenyFilter and XMLDenyFilter are self made filters or do i have two build two classes extending these filters. In case so where i have to save these filter classes. ur help is really useful to me - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Log4J-System-alerts-tf2727572.html#a7620955 Sent from the Log4j - Users mailing list archive at Nabble.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]
RE: [SPAM (Bayesain Analysis)] - Logging Cross Functional categories in log4j - Bayesian Filter detected spam
Already considered to use MDC? i.e.: MDC.put( category_tech, EJB ) MDC.put( category_func, Plan ) try { myLog.x } finally { MDC.remove( category_tech ); MDC.remove( category_func ); } The pattern can resolve this MDC values with the %X switch: %X{category_tech} %X{category_func} Heri -Original Message- From: GoodOne [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 25, 2006 6:54 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Logging Cross Functional categories in log4j - Bayesian Filter detected spam Hello All, This is my first posting so please bear with me. I am using log4j and I would like to log based on technical and functional partitions of the application so that I can filter logs later. So technical partition would include EJB, Persistence, Servlet, BusinessTier etc while functional partition could include Accounts,Servicing,Plan,Infrastructure etc. One idea is I could take a cartesian product as categories. Any other ideas are welcome. Thank you. The Good one. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Logging Cross Functional categories in log4j
You can write your own Filter class where you can use your MDC value. Filter classes are not supported in Property configuration, only in XML configuration. Heri -Original Message- From: GoodOne [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 25, 2006 7:58 PM To: Log4J Users List Subject: [SPAM (Keyword Checking)] - Re: [SPAM (Bayesain Analysis)] - Logging Cross Functional categories in log4j - Bayesian Filter detected spam - Found word(s) remove list in the Text body Thank you. But if I want to change the debug level in config file for EJBs across all functional partitions like Accounts,Servicing,Plan,Infrastructure etc, would it be possible if i use MDC values? On 10/25/06, Bender Heri [EMAIL PROTECTED] wrote: Already considered to use MDC? i.e.: MDC.put( category_tech, EJB ) MDC.put( category_func, Plan ) try { myLog.x } finally { MDC.remove( category_tech ); MDC.remove( category_func ); } The pattern can resolve this MDC values with the %X switch: %X{category_tech} %X{category_func} Heri -Original Message- From: GoodOne [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 25, 2006 6:54 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Logging Cross Functional categories in log4j - Bayesian Filter detected spam Hello All, This is my first posting so please bear with me. I am using log4j and I would like to log based on technical and functional partitions of the application so that I can filter logs later. So technical partition would include EJB, Persistence, Servlet, BusinessTier etc while functional partition could include Accounts,Servicing,Plan,Infrastructure etc. One idea is I could take a cartesian product as categories. Any other ideas are welcome. Thank you. The Good one. - 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]
RE: configuration file in Eclipse
I assume this is a classpath issue. How do you use your path reference? How do you load the property file? Heri -Original Message- From: Ben Lajeunesse [mailto:[EMAIL PROTECTED] Sent: Monday, October 23, 2006 4:56 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - configuration file in Eclipse - Bayesian Filter detected spam Does anyone know how to reference a relative path configuration file in an Eclipse project? It seems that relative paths do not work (from the root of the project), only absolute paths...and I need this project to be deployable reguardless of installation path (I need relative path). Thanks, Ben. _ Say hello to the next generation of Search. Live Search - try it now. http://www.live.com/?mkt=en-ca - 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]
logging into different files
This was discussed a lot on this list. Search in archive, keywords: MDC, RepositorySelector, different files. We currently discuss on the developper list the introduction of a MultiFileAppender which addresses just your need. But the work is still in progress... Heri -Original Message- From: sudhakardvvn [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 11, 2006 1:49 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - logging into different files - Bayesian Filter detected spam Have an application where the number of threads that get launched are dynamic. Could be anywhere from 1 to 300 threads that could get launched at runtime. I would like to know if it is possible to setup a file appender for each thread and have the indiv threads write to their own file appender. Currently all threads write to one log file using 1 file appender in a log4j.properties file but would like ability for each thread to log its own messages for easier debugging. Any good sites or source would be great. Any help would be appreciated. -- View this message in context: http://www.nabble.com/logging-into-different-files-tf2422885.h tml#a6754850 Sent from the Log4j - Users mailing list archive at Nabble.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]
Re: How to filter specific characters to not to log
A common way to enter binary data in xml is - use base64 encoding (not readable for humans, size is one third bigger than original) - translate to hex string (readable for humans, size is twice as big than original) Heri -Original Message- From: Praveen Kumar Hasthalapuram [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 19, 2006 8:03 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Re: How to filter specific characters to not to log - Bayesian Filter detected spam Hi Curt, We are facing problems with this chatacter #0; issue, Is there any standard convention for representing a character of value 0 in XML (and other control characters)? I understand that we can't actually *have* such a character - that's why #0; is illegal - but sometimes we want to output data that includes such characters. or How to escape these characters in xml report. Regards, Praveen On 9/19/06, Curt Arnold [EMAIL PROTECTED] wrote: XMLLayout in both 1.2 and 1.3 can produce bad XML in several scenarios as reported in bugs 29244, 34875 and 37560. Since I was an XML guru in a former life, I know of additional holes in the implementation. If you'd be interested in testing it, I could take a shot at re-implementing XMLLayout. I think that would be a better solution than trying to filter content to avoid the bugs. On Sep 18, 2006, at 1:09 PM, Praveen Kumar Hasthalapuram wrote: Hi, We will get these characters from the devices and these data we will log. These logged data will be used to generate xml reports. With some devices we are getting some control characters (some spl symbols) and these are causing xml report to fail. Is it possible to strip this characters or filter this types of characters. Regards, Praveen - 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]
Re: problem with alternative log4j.properties-file
1. It is not recommended to subclass Logger. It would be better to write a Wrapper if you have particular business rules to implement. 2. In order to analyze your problem you should provide more details: - original property file - alternative property file - name(s) of involved loggers - Where do you call te code below? Heri -Original Message- From: Paulicke Stephan (KISP 53) [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 20, 2006 3:10 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - problem with alternative log4j.properties-file - Bayesian Filter detected spam hi, i wote a small application (contained in a .jar-file) which also includes a log4j.properties file. i also wrote my own logger which depends on org.apache.log4j.Logger everthing works fine so far. i included a parameter to define an alternative log4j.properties file that should be used: logProps.load(new FileInputStream(logPropFile)); PropertyConfigurator.configure(logProps); if i use this, the logfile will be empty. this was working before i created my own logger. any ideas? thanx in advance stephan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Enhanced FileAppender (Was: Separate log files per thread.)
This problem arises often. Some want to separate the log files of servlets by different criterias (sessionID, userID, etc.), others (like me) have a scheduler which fires different tasks on different customers where the log output should be separated. I thought one could enhance the file appender itself by suppliying it with a kind of FileNameBuilder-Class. So this enhancement would apply to all descendants of file appender (Rolling, DailyRolling, etc.). The FileNameBuilder could build the filename by using values of MDC or any other criterias, and the file appender can then hold a bundle of different targets, like described below by Curt Arnold. In my opinion this would be more flexible than a hard coded pattern which just relys on the thread name. Any thoughts? Heri -Original Message- From: Curt Arnold [mailto:[EMAIL PROTECTED] Sent: Friday, September 15, 2006 6:19 PM To: Log4J Users List Subject: [SPAM (Bayesain Analysis)] - Re: Separate log files per thread. - Bayesian Filter detected spam On Sep 14, 2006, at 4:11 PM, James Stauffer wrote: 4. Write your own appender that potentially changes the logfile name per logging event. I do a smiliar thing with an appender. http://stauffer.james.googlepages.com/DateFormatFileAppender.java 5. Discuss the requirements for such an appender on the mailing list and see if a consensus could be formed. If so, a sandbox project could be started to develop the appender and when functional it might get added into log4j itself. You also might check if log4net might already have something similar and if so, we might port it back from there. I thought about it a little. It was thinking that you might specify a java.text.MessageFormat pattern for file name using Thread.getName () (or Thread.toString() if name was blank), the maximum number of open files, plus the WriterAppender properties. The appender would keep a hashmap of Writers keyed by the generated file name and would maintain it so it closed the stalest Writer if the open file count would have been exceeded. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to filter specific characters to not to log
Can you explain where these characters occur? Are they within a String supplied as msg argument in log calls? Or where? Heri -Original Message- From: Praveen Kumar Hasthalapuram [mailto:[EMAIL PROTECTED] Sent: Monday, September 18, 2006 4:02 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - How to filter specific characters to not to log - Bayesian Filter detected spam Hi, I want to filter some specific characters (special chars) , so that it should not log. Can anyone suggest me how to it? Thanks, Praveen - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]