On Oct 19, 2008, at 11:06 PM, Ole Ersoy wrote:

Hi,

I'm attempting to setup an test for logging with syslog to /var/log/ test.log. So far I have this:

public class Log4JTest    extends TestCase
{
        Logger logger = Logger.getLogger(Log4JTest.class.getName());
        
        
        
        public void setUp()
        {

                SyslogAppender syslogAppender = new SyslogAppender();
                
                BasicConfigurator.configure();


BasicConfigurator creates a ConsoleAppender and attaches it to the root logger.



                
                logger.addAppender(syslogAppender);
                
                syslogAppender.setSyslogHost("localhost");
                
                syslogAppender.setFacility("?????");
                
                syslogAppender.setLayout(new PatternLayout());


activateOptions() should be called after properties are set to make them effective. I'd suggest removing the earlier logger.addAppender() and adding:

                    syslogAppender.activateOptions();
                    logger.addAppender(syslogAppender);



        }
  public void testApp()
  {
        logger.info("I'm logging with syslog");
   }
}

Does anyone know what I need to pass to setFacility, and whether I need to make any adjustments in /etc/rsyslog.conf for this to work?

Thanks,
- Ole


As mentioned in the previous email, SyslogAppender writes to a network socket to perform syslogging even when logging to the local machine. Any other approach would require native code. There is a feature request for a native code SyslogAppender, but there has not been any activity.

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

Reply via email to