Re: Newbie – log4j and syslog-ng setup

2006-08-14 Thread James Stauffer

You only showed your appender config.  Are you use the messages are
getting to the appender.

If you run with -Dlog4j.debug it might give you helpful info.

On 8/14/06, theMonkyBoy [EMAIL PROTECTED] wrote:


Hi,

sorry for this post, but I've been searching for a couple of days now and
found nothing to help me get started via google!

In our environment we currently have a cluster of J2EE servers, where each
member writes to their own log file. Now we would like to also write to one
consolidated log file. So it has been envisaged that each cluster member
writes to their own syslog-ng deamon, who then in turn forwards messages on
to a central logging server.

I have a couple of problems here. Reading through the posts I have seen
people are using the SyslogAppender to get log4j to write to the syslog-nd
deamon. I have tried two configurations for this.


appender name=SYSLOG class=org.apache.log4j.net.SyslogAppender
param name=SyslogHost value=127.0.0.1/
param name=Facility value=USER/
param name=FacilityPrinting value=true/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%p: %c - %m/
/layout
/appender

and:

log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.syslogHost=127.0.0.1
log4j.appender.SYSLOG.Facility=USER
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.ConversionPattern=%p: %c - %m


I then try to use a very simple program to print to this appender:


package com.foo.bar;

import org.apache.log4j.Logger;

public class LogStuff
{
  Logger log = Logger.getLogger( LogStuff.class );

  public static void main(String [] argv)
  {
new LogStuff().doIt();
  }

  private void doIt()
  {
log.debug( Hello world! );
log.info( Hello world! );
log.warn( Hello world! );
log.error( Hello world! );
log.fatal( Hello world! );
  }
}


When I then check the syslog-ng files I find nothing in there. So I guess
there is some configuration to do on that side.

So I started to hack the syslog-ng.conf file.

source s_j2ee { unix-stream(/dev/log); internal(); };
destination d_j2ee { file(/var/log/j2ee.log); };
log { source(s_j2ee); destination(d_j2ee); };

As some of the internal syslog-ng messages are arriving in my log file I
assume that some of this configuration is correct. However, as no java
messages are being received I assume that I've not set up the source
correctly.

Through all my searched I was unable to find the source that log4j will use.
Can someone point me in the right direction?

Are there any good resources available that I can read?

Thanks in advance for your help

--
View this message in context: 
http://www.nabble.com/Newbie--log4j-and-syslog-ng-setup-tf2103256.html#a5796385
Sent from the Log4j - Users forum at Nabble.com.


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





--
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]



Re: Newbie – log4j and syslog-ng setup

2006-08-14 Thread theMonkyBoy

Hi James,

Thanks for your reply.


James Stauffer wrote:
 
 You only showed your appender config.  Are you use the messages are
 getting to the appender.
 


Here is my complete log4j.xml configuration file:


?xml version=1.0 encoding=UTF-8?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;

appender name=SYSLOG class=org.apache.log4j.net.SyslogAppender
param name=SyslogHost value=localhost/
param name=Facility value=USER/
param name=FacilityPrinting value=true/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%p: %c - %m/
/layout
/appender

appender name=STDOUT class=org.apache.log4j.ConsoleAppender
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p %c 
%x - %m%n/
/layout
/appender

appender name=LOGFILE class=org.apache.log4j.FileAppender
  param name=File value=/tmp/log4j.log /
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p %c 
%x - %m%n/
/layout
/appender

root
level value=debug/
appender-ref ref=STDOUT/
appender-ref ref=LOGFILE/
appender-ref ref=SYSLOG/
/root

/log4j:configuration


I am getting messages to the console and also in the log file, so I am
assuming that the log4j config is working and therefore something on the
syslog-ng side isn't configured as it should be.




James Stauffer wrote:
 
 If you run with -Dlog4j.debug it might give you helpful info.
 

Thanks for the debug tip, I was completely unaware of that one. This is the
console output when running with the debug flag set. As you can see at the
end my log4j messages are output:

log4j: Trying to find [log4j.xml] using context classloader
[EMAIL PROTECTED]
log4j: Using URL [file:/cc.project/log4j/target/classes/log4j.xml] for
automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is:
org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= null.
log4j: Ignoring debug attribute.
log4j: Threshold =null.
log4j: Level value for root is  [debug].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c %x - %m%n].
log4j: Adding appender named [STDOUT] to category [root].
log4j: Class name: [org.apache.log4j.FileAppender]
log4j: Setting property [file] to [/tmp/log4j-syslog.log].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c %x - %m%n].
log4j: setFile called: /tmp/log4j-syslog.log, true
log4j: setFile ended
log4j: Adding appender named [LOGFILE] to category [root].
log4j: Class name: [org.apache.log4j.net.SyslogAppender]
log4j: Setting property [syslogHost] to [localhost].
log4j: Setting property [facility] to [USER].
log4j: Setting property [facilityPrinting] to [true].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%p: %c - %m].
log4j: Adding appender named [SYSLOG] to category [root].
2006-08-14 17:18:04,574 [main] DEBUG ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,577 [main] INFO  ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,578 [main] WARN  ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,578 [main] ERROR ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,578 [main] FATAL ch.cablecom.log4j.LogStuff  - Hello
world!





James Stauffer wrote:
 
 On 8/14/06, theMonkyBoy [EMAIL PROTECTED] wrote:

 Hi,

 sorry for this post, but I've been searching for a couple of days now and
 found nothing to help me get started via google!

 In our environment we currently have a cluster of J2EE servers, where
 each
 member writes to their own log file. Now we would like to also write to
 one
 consolidated log file. So it has been envisaged that each cluster member
 writes to their own syslog-ng deamon, who then in turn forwards messages
 on
 to a central logging server.

 I have a couple of problems here. Reading through the posts I have seen
 people are using the SyslogAppender to get log4j to write to the
 syslog-nd
 deamon. I have tried two configurations for this.


 appender name=SYSLOG class=org.apache.log4j.net.SyslogAppender
 param name=SyslogHost value=127.0.0.1/
 param name=Facility value=USER/
 param name=FacilityPrinting value=true/
 layout 

Re: Newbie – log4j and syslog-ng setup

2006-08-14 Thread James Stauffer

Ok then I don't have any more advice because I hadn't used that appender.

On 8/14/06, theMonkyBoy [EMAIL PROTECTED] wrote:


Hi James,

Thanks for your reply.


James Stauffer wrote:

 You only showed your appender config.  Are you use the messages are
 getting to the appender.



Here is my complete log4j.xml configuration file:


?xml version=1.0 encoding=UTF-8?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/;

appender name=SYSLOG class=org.apache.log4j.net.SyslogAppender
param name=SyslogHost value=localhost/
param name=Facility value=USER/
param name=FacilityPrinting value=true/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%p: %c - %m/
/layout
/appender

appender name=STDOUT class=org.apache.log4j.ConsoleAppender
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p %c %x - 
%m%n/
/layout
/appender

appender name=LOGFILE class=org.apache.log4j.FileAppender
  param name=File value=/tmp/log4j.log /
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p %c %x - 
%m%n/
/layout
/appender

root
level value=debug/
appender-ref ref=STDOUT/
appender-ref ref=LOGFILE/
appender-ref ref=SYSLOG/
/root

/log4j:configuration


I am getting messages to the console and also in the log file, so I am
assuming that the log4j config is working and therefore something on the
syslog-ng side isn't configured as it should be.




James Stauffer wrote:

 If you run with -Dlog4j.debug it might give you helpful info.


Thanks for the debug tip, I was completely unaware of that one. This is the
console output when running with the debug flag set. As you can see at the
end my log4j messages are output:

log4j: Trying to find [log4j.xml] using context classloader
[EMAIL PROTECTED]
log4j: Using URL [file:/cc.project/log4j/target/classes/log4j.xml] for
automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is:
org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= null.
log4j: Ignoring debug attribute.
log4j: Threshold =null.
log4j: Level value for root is  [debug].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c %x - %m%n].
log4j: Adding appender named [STDOUT] to category [root].
log4j: Class name: [org.apache.log4j.FileAppender]
log4j: Setting property [file] to [/tmp/log4j-syslog.log].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c %x - %m%n].
log4j: setFile called: /tmp/log4j-syslog.log, true
log4j: setFile ended
log4j: Adding appender named [LOGFILE] to category [root].
log4j: Class name: [org.apache.log4j.net.SyslogAppender]
log4j: Setting property [syslogHost] to [localhost].
log4j: Setting property [facility] to [USER].
log4j: Setting property [facilityPrinting] to [true].
log4j: Parsing layout of class: org.apache.log4j.PatternLayout
log4j: Setting property [conversionPattern] to [%p: %c - %m].
log4j: Adding appender named [SYSLOG] to category [root].
2006-08-14 17:18:04,574 [main] DEBUG ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,577 [main] INFO  ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,578 [main] WARN  ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,578 [main] ERROR ch.cablecom.log4j.LogStuff  - Hello
world!
2006-08-14 17:18:04,578 [main] FATAL ch.cablecom.log4j.LogStuff  - Hello
world!





James Stauffer wrote:

 On 8/14/06, theMonkyBoy [EMAIL PROTECTED] wrote:

 Hi,

 sorry for this post, but I've been searching for a couple of days now and
 found nothing to help me get started via google!

 In our environment we currently have a cluster of J2EE servers, where
 each
 member writes to their own log file. Now we would like to also write to
 one
 consolidated log file. So it has been envisaged that each cluster member
 writes to their own syslog-ng deamon, who then in turn forwards messages
 on
 to a central logging server.

 I have a couple of problems here. Reading through the posts I have seen
 people are using the SyslogAppender to get log4j to write to the
 syslog-nd
 deamon. I have tried two configurations for this.


 appender name=SYSLOG class=org.apache.log4j.net.SyslogAppender
 param name=SyslogHost