Re: Log4j Configuration
Your explanation is a lot better than those I found on web. Thx. I still have some questions, see below: - Original Message - From: <[EMAIL PROTECTED]> To: "Log4J Users List" Sent: Wednesday, August 17, 2005 8:43 AM Subject: Re: Log4j Configuration "William Mok" <[EMAIL PROTECTED]> wrote on 08/16/2005 03:59:25 PM: Thanks. Your explanation make everything much clearer. I modified the log4j.properties file and run the servlet again, I can only see empty file axis.log being created but there is no logging inside. The issue with that is most likely one of two things: * The logging level is set so that debug or info messages are not being sent, so you won't see any messages unless something bad happens (warn, error, fatal). Try knocking down the logging level to debug and see if you get anything. * From your previous code, it looks like you had the axis.log appender attached to classes in the org.apache.axis.enterprise package and below. That's Axis code, not your own. So when you do the Logger.getLogger() call on your own class (EchoService?), it's actually retrieving a logger for com.mycompany.mypackage.echo.EchoService, or whatever the package is that contains that class. If there are no loggers defined for any level of that hierarchy (i.e. com, com.mycompany, com.mycompany.mypackage, etc.), then you'll get the root category logger. Try redefining that logger to something like: # Set the my logger to DEBUG and add the my appender. log4j.logger.com.mycompany.mypackage.echo=DEBUG, CONSOLE, ECHO # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender ... # ECHO is set to be a File appender using a PatternLayout. log4j.appender.ECHO=org.apache.log4j.FileAppender ... Look at the call to Logger.getLogger(EchoService.class): what it does is retrieves the fully qualified name of that class, e.g. com.mycompany.mypackage.echo.EchoService. It then looks for a logger defined for com.mycompany.mypackage.echo.EchoService. If it doesn't find that, it'll look for the next step up the hierarchy, i.e. com.mycompany.mypackage.echo, then com.mycompany.mypackage, and so on. Once you've defined this logger for com.mycompany.mypackage.echo, that's what it'll find. It will then write whatever messages you send to that logger to the defined appenders, as long as those messages have the effective level of the logger or above. I am a bit confused about the rootlogger and childlogger concepts, what's the reason behind having different logging hierarchy? What does the rootLogger actually do? , i.e. when do I use the rootLogger? Also the check for ClassLoader seems to fail, i.e. cl = NULL as I cannot find the "Search and destroy" in any logs. That's probably because the stdout is being diverted somewhere. If you're running your servlet container (e.g. Tomcat) from a shell script, then that message will be displayed on the actual console. If you're running from a service on Windows or some other script on *nix, then stdout is usually diverted to something like localhost_log..txt or something like that. Another option is to replace the System.out.println() call by opening a file in a known location and writing out to that. It's completely impossible that you're not getting a class loader, otherwise... well, none of your classes would load :^) That's correct, if I run it using Eclipse, I can see the "search and destroy" on the Eclipse console but not appearing in any of the logs. However, I believe the log4j.properties has been picked up otherwise the axis.log file will not be created. Definitely. That right there proves that your instance of log4j.properties is being loaded. - 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 level color
In Chainsaw V2 we use tablecolorizingrenderer and colorizer to render rows in the table. Here's the source: http://cvs.apache.org/viewcvs.cgi/logging-chainsaw/src/java/org/apache/l og4j/chainsaw/TableColorizingRenderer.java?rev=1.18&view=markup http://cvs.apache.org/viewcvs.cgi/logging-chainsaw/src/java/org/apache/l og4j/chainsaw/color/Colorizer.java?rev=1.3&view=markup Scott -Original Message- From: LARRY LOPEZ [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 2:19 PM To: 'Log4J Users List' Subject: RE: setting level color I created a new appender that logs to a swing window, I was wondering if each level can be set to a color for user viewing. I am running Chainsaw, but for the users who are not using chainsaw, they can view the log messages with this window. Right now all the messages are printed black, I was wondering if there is a way to set each level to a specific color? -Original Message- From: Harp, George [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 2:11 PM To: 'Log4J Users List' Subject: RE: setting level color Using chainsaw maybe -Original Message- From: LARRY LOPEZ [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 4:08 PM To: log4j-user@logging.apache.org Subject: setting level color Is it possible to set a level to a specific color? - 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]
question
Hi, Is there a way to change the color of debug, info, error and warn in the console?
RE: setting level color
I created a new appender that logs to a swing window, I was wondering if each level can be set to a color for user viewing. I am running Chainsaw, but for the users who are not using chainsaw, they can view the log messages with this window. Right now all the messages are printed black, I was wondering if there is a way to set each level to a specific color? -Original Message- From: Harp, George [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 2:11 PM To: 'Log4J Users List' Subject: RE: setting level color Using chainsaw maybe -Original Message- From: LARRY LOPEZ [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 4:08 PM To: log4j-user@logging.apache.org Subject: setting level color Is it possible to set a level to a specific color? - 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 level color
Using chainsaw maybe -Original Message- From: LARRY LOPEZ [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 4:08 PM To: log4j-user@logging.apache.org Subject: setting level color Is it possible to set a level to a specific color? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
setting level color
Is it possible to set a level to a specific color?
Re: seize all logging messages?
On Aug 17, 2005, at 1:17 AM, Adam Megacz wrote: Assuming that log4j is up and running in some unknown state, is there any way to programmatically intercept all log messages and "do something" with them? With Bender Hari's suggestion I believe you would be limited to only capturing the message part of the logging request and would lose time- stamp, logger name, NDC, MDC and the like. You would also see only those logging requests that passed the threshold tests to get into the dispatching pipeline. If, for example, you wanted to see all logging requests even though log4j was configured to turn logging off, the approach would not work since the logging requests would never get into the dispatching pipeline. Most of the log4j docs seem oriented towards static configuration (properties files) rather than dynamic configuration. The documentation is oriented that way since that is the more common way to use log4j. However, the configurators use public methods that any app can call to configure log4j and the configuration can be changed during the application lifetime. The way you phrased the question appears that you want to countermand or veto an explicit configuration decision made earlier. log4j doesn't make it easy for you to fight or override an earlier configuration (you can however reset it and start again). When and how log4j is configured is controlled by the calling application, so you should make your life easier by controlling how log4j is configured. If you give more details of the situation that you are facing, maybe we can give you better advice. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassNotFoundException: LogFilePatternReceiver- 2
Hi , Thanks a lot. This suggestion worked. Regards Sampath -Original Message- From: Pugazholi Thyagarasan [mailto:[EMAIL PROTECTED] Sent: Monday, August 15, 2005 10:45 PM To: Log4J Users List Subject: Re: ClassNotFoundException: LogFilePatternReceiver- 2 I had the same issue. Try adding jakarta-oro-2.0.6.jar to the class path. After few trial and errors below works fine for me, java -classpath log4j-1.3alpha-7.jar;log4j-chainsaw-1.3alpha-7.jar;ugli- simple.jar;log4j-xml.jar;log4j-optional.jar;commons-vfs-1.0-RC2.jar;comm ons- logging.jar;commons-logging-api.jar;commons-net-1.4.0.jar;jsch-0.1.21.ja r ;jakarta-oro-2.0.6.jar;log4j-oro.jar org.apache.log4j.chainsaw.LogUI On 8/11/05, Manda, Sampath (Contractor) <[EMAIL PROTECTED]> wrote: > > > Hi , > > Would appreciate if any one could spend some time on the below issue. > Hope this is a Known Issue and someone knows the solution out there. > > Thanks a lot > Sampath > > > -Original Message- > > From: Manda, Sampath (Contractor) > > Sent: Wednesday, August 10, 2005 1:30 PM > > To: 'log4j-user@logging.apache.org' > > Subject: ClassNotFoundException: LogFilePatternReceiver > > > > > > > > Hi , > > > > I am using the latest version of chainsaw (local copy and using > > chainsaw.bat) > > > > > > Below is chainsaw configuration > > > > > > > class="org.apache.log4j.varia.LogFilePatternReceiver"> > > > > > > > > > > > > > > > > > > > > Unable to add a receiver due to the below exception. > > ClassNotFoundException: > > org.apache.log4j.varia.LogFilePatternReceiver > > > > This class is present in log4j-oro.jar . But if I add this in > > classpath ( in chainsaw.bat) chainsaw itself does not start > > > > > > > > Request help at the earliest. > > > > > > Thanks > > Sampath > > > > > > > > > > LOG4J-INTERNAL: 2005-08-10 13:11:11,679 ERROR [Thread-8] > > org.apache.log4j.helpers.OptionConverter#instantiateByClassName:363) > > - > > C > > ould not instantiate object of class > > [org.apache.log4j.varia.LogFilePatternReceiver]. > > java.lang.ClassNotFoundException: > > org.apache.log4j.varia.LogFilePatternReceiver > > at java.net.URLClassLoader$1.run(Unknown Source) > > at java.security.AccessController.doPrivileged(Native Method) > > at java.net.URLClassLoader.findClass(Unknown Source) > > at java.lang.ClassLoader.loadClass(Unknown Source) > > at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) > > at java.lang.ClassLoader.loadClass(Unknown Source) > > at java.lang.ClassLoader.loadClassInternal(Unknown Source) > > at java.lang.Class.forName0(Native Method) > > at java.lang.Class.forName(Unknown Source) > > at org.apache.log4j.helpers.Loader.loadClass(Loader.java:162) > > at > > org.apache.log4j.helpers.OptionConverter.instantiateByClassName(Option > > Converter.java:340) > > at > > org.apache.log4j.joran.action.PluginAction.begin(PluginAction.java:47) > > at > > org.apache.log4j.joran.spi.Interpreter.callBeginAction(Interpreter.jav > > a:239) > > at > > org.apache.log4j.joran.spi.Interpreter.startElement(Interpreter.java:1 > > 31) > > at > > org.apache.log4j.joran.spi.JoranDocument$StartElementEvent.replay(Jora > > nDocument.java:225) > > at > > org.apache.log4j.joran.spi.JoranDocument.replay(JoranDocument.java:113 > > ) > > at > > org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator > > .java:170) > > at > > org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator > > .java:89) > > at > > org.apache.log4j.chainsaw.LogUI.loadConfigurationUsingPluginClassLoade > > r(LogUI.java:1846) > > at org.apache.log4j.chainsaw.LogUI.access$1800(LogUI.java:134) > > at org.apache.log4j.chainsaw.LogUI$43.run(LogUI.java:1318) > > at java.lang.Thread.run(Unknown Source) > > LOG4J-INTERNAL: 2005-08-10 13:11:11,689 ERROR [Thread-8] > > org.apache.log4j.joran.action.PluginAction#begin:70)- Could not create > > a plugin. Reported error follows. > > java.lang.NullPointerException > > at > > org.apache.log4j.joran.action.PluginAction.begin(PluginAction.java:57) > > at > > org.apache.log4j.joran.spi.Interpreter.callBeginAction(Interpreter.jav > > a:239) > > at > > org.apache.log4j.joran.spi.Interpreter.startElement(Interpreter.java:1 > > 31) > > at > > org.apache.log4j.joran.spi.JoranDocument$StartElementEvent.replay(Jora > > nDocument.java:225) > > at > > org.apache.log4j.joran.spi.JoranDocument.replay(JoranDocument.java:113 > > ) > > at > > org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator > > .java:170) > > at > > org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator > > .java:89) > > at > > org.apache.log4j.chainsaw.LogUI.loadConfigurationUsingPluginClassLoade > > r(LogUI.java:1846) > > at org.apache.log4j.chainsaw.LogUI.access$1800(LogUI.java:134) > > at org.apache.log4j.chainsaw.LogUI$43.run(LogUI.java:1318) > > at java.lang.Thread.run(Unknown Source).. > > . > > > > > > 71994 [Thread-8] WARN org.apache.log4j.config.Pro
RE: WriterAppender to sockets
As far as I understand log4j takes the log object and serializes it before sending it via socketappender. I have a feeling this will greatly limit "complete control". -Original Message- From: Benjamin David [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 17, 2005 10:41 AM To: Log4J Users List Subject: Re: WriterAppender to sockets When using SocketAppender / SocketHubAppender , Log4j sends the log info to a log server which listens to a socket. However, I want to send the log info to a socket which I will have complete control over, without using the log server infrastructure. Thanks, Ben On 8/17/05, Bradley, Todd <[EMAIL PROTECTED]> wrote: > > I do not want to use the SocketAppender as I need to log to > > the socket itself. > > I don't understand this sentence. SocketAppender and > SocketHubAppender are both ways of "logging to a socket" > so there must be something I'm missing here. > > > Todd. > > - > 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: Log4j Configuration
"William Mok" <[EMAIL PROTECTED]> wrote on 08/16/2005 03:59:25 PM: > Thanks. Your explanation make everything much clearer. > > I modified the log4j.properties file and run the servlet again, I can only > see empty file axis.log being created but there is no logging inside. The issue with that is most likely one of two things: * The logging level is set so that debug or info messages are not being sent, so you won't see any messages unless something bad happens (warn, error, fatal). Try knocking down the logging level to debug and see if you get anything. * From your previous code, it looks like you had the axis.log appender attached to classes in the org.apache.axis.enterprise package and below. That's Axis code, not your own. So when you do the Logger.getLogger() call on your own class (EchoService?), it's actually retrieving a logger for com.mycompany.mypackage.echo.EchoService, or whatever the package is that contains that class. If there are no loggers defined for any level of that hierarchy (i.e. com, com.mycompany, com.mycompany.mypackage, etc.), then you'll get the root category logger. Try redefining that logger to something like: # Set the my logger to DEBUG and add the my appender. log4j.logger.com.mycompany.mypackage.echo=DEBUG, CONSOLE, ECHO # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender ... # ECHO is set to be a File appender using a PatternLayout. log4j.appender.ECHO=org.apache.log4j.FileAppender ... Look at the call to Logger.getLogger(EchoService.class): what it does is retrieves the fully qualified name of that class, e.g. com.mycompany.mypackage.echo.EchoService. It then looks for a logger defined for com.mycompany.mypackage.echo.EchoService. If it doesn't find that, it'll look for the next step up the hierarchy, i.e. com.mycompany.mypackage.echo, then com.mycompany.mypackage, and so on. Once you've defined this logger for com.mycompany.mypackage.echo, that's what it'll find. It will then write whatever messages you send to that logger to the defined appenders, as long as those messages have the effective level of the logger or above. > Also the check for ClassLoader seems to fail, i.e. cl = NULL as I cannot > find the "Search and destroy" in any logs. That's probably because the stdout is being diverted somewhere. If you're running your servlet container (e.g. Tomcat) from a shell script, then that message will be displayed on the actual console. If you're running from a service on Windows or some other script on *nix, then stdout is usually diverted to something like localhost_log..txt or something like that. Another option is to replace the System.out.println() call by opening a file in a known location and writing out to that. It's completely impossible that you're not getting a class loader, otherwise... well, none of your classes would load :^) > However, I believe the log4j.properties has been picked up otherwise the > axis.log file will not be created. Definitely. That right there proves that your instance of log4j.properties is being loaded. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: WriterAppender to sockets
When using SocketAppender / SocketHubAppender , Log4j sends the log info to a log server which listens to a socket. However, I want to send the log info to a socket which I will have complete control over, without using the log server infrastructure. Thanks, Ben On 8/17/05, Bradley, Todd <[EMAIL PROTECTED]> wrote: > > I do not want to use the SocketAppender as I need to log to > > the socket itself. > > I don't understand this sentence. SocketAppender and > SocketHubAppender are both ways of "logging to a socket" > so there must be something I'm missing here. > > > Todd. > > - > 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: seize all logging messages?
And if you want the program that does something with the log messages to be on a different machine, use a SocketAppender or SocketHubAppender. Todd. > -Original Message- > From: Bender Heri [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 17, 2005 2:00 AM > To: Log4J Users List > Subject: RE: seize all logging messages? > > Derive a class from ObjectRenderer and define which class > should be rendered by your new renderer: > > renderingClass="foo.bar.myRenderer"/> > > Then you overwrite the method doRender(), where you obtain > the String as parameter. Do whatever you like with it and > return your result as a rendered string. > > You can also render any other class withing a specialized > custom renderer. Remeber that the parameter of a log call > (i.e. myLogger.info( ... ) ) is formally an abstract Object > and not a String. So you can pass any object to the logger. > The logger framework will pass the received object to the > appropriate renderer in order to transform it to an output string. > > Heri > > > > -Original Message- > > From: news [mailto:[EMAIL PROTECTED] Behalf Of Adam Megacz > > Sent: Wednesday, August 17, 2005 8:17 AM > > To: log4j-user@logging.apache.org > > Subject: seize all logging messages? > > > > > > > > Assuming that log4j is up and running in some unknown > state, is there > > any way to programmatically intercept all log messages and "do > > something" with them? > > > > Most of the log4j docs seem oriented towards static configuration > > (properties files) rather than dynamic configuration. > > > > - a > > > > -- > > PGP/GPG: 5C9F F366 C9CF 2145 E770 B1B8 EFB1 462D A146 C380 > > > > > > > - > > 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: WriterAppender to sockets
> I do not want to use the SocketAppender as I need to log to > the socket itself. I don't understand this sentence. SocketAppender and SocketHubAppender are both ways of "logging to a socket" so there must be something I'm missing here. Todd. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using property to set logger level
You could use different log4j.xml files for each way to start the program. On 8/17/05, Hein Meling <[EMAIL PROTECTED]> wrote: > The reason I want this, is since I have two different ways of starting > the RegistryImpl class and I want to reduce the level of log stuff that > gets sent to STDOUT in one case but not in the other. I would like to > avoid having two separate log4j.xml files for such a minor change. -- James Stauffer Are you good? Take the test at http://www.livingwaters.com/good/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
WriterAppender to sockets
Hi, I am enquiring about the use of WriterAppender with sockets. I would like to use a WriterAppender that would log to an OutputStream, more precisely a socket to another machine. As far as I can see this is not currently supported, as the process on the other side reads in an EOF from this socket and no information is retrieved. This is surprising as the WriterAppender works with files, which are output streams as well. I do not want to use the SocketAppender as I need to log to the socket itself. Is there any plan to implement this the WriterAppender for sockets ? Thanks, Ben - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using property to set logger level
Hi Is it not possible to set the logger level using something like: I'm using properties to configure the file name of appenders (see below) and thought that the above would work, but it didn't. The reason I want this, is since I have two different ways of starting the RegistryImpl class and I want to reduce the level of log stuff that gets sent to STDOUT in one case but not in the other. I would like to avoid having two separate log4j.xml files for such a minor change. Any reason why not allow this, or is it just not implemented? I'm using log4j v1.3 alpha3. Thanks, Hein - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: seize all logging messages?
Derive a class from ObjectRenderer and define which class should be rendered by your new renderer: Then you overwrite the method doRender(), where you obtain the String as parameter. Do whatever you like with it and return your result as a rendered string. You can also render any other class withing a specialized custom renderer. Remeber that the parameter of a log call (i.e. myLogger.info( ... ) ) is formally an abstract Object and not a String. So you can pass any object to the logger. The logger framework will pass the received object to the appropriate renderer in order to transform it to an output string. Heri > -Original Message- > From: news [mailto:[EMAIL PROTECTED] Behalf Of Adam Megacz > Sent: Wednesday, August 17, 2005 8:17 AM > To: log4j-user@logging.apache.org > Subject: seize all logging messages? > > > > Assuming that log4j is up and running in some unknown state, is there > any way to programmatically intercept all log messages and "do > something" with them? > > Most of the log4j docs seem oriented towards static configuration > (properties files) rather than dynamic configuration. > > - a > > -- > PGP/GPG: 5C9F F366 C9CF 2145 E770 B1B8 EFB1 462D A146 C380 > > > - > 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]