New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate graylogs own logs log4j #1042

Closed
1tft opened this Issue Mar 6, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@1tft

1tft commented Mar 6, 2015

Hello, regarding http://docs.graylog.org/en/1.0/pages/installation.html#supplying-external-logging-configuration I configured graylog start script with
LOG4J=${LOG4J:=-Dlog4j.configuration=file:///tmp/log4j.xml}

After restarting graylog I get the following graylog error msg:

log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassNotFoundException: org.apache.log4j.rolling.RollingFileAppender
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:260)
    at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
    at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:247)
    at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
    at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
    at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
    at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
    at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1006)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:285)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:305)
    at org.graylog2.bootstrap.CmdLineTool.<clinit>(CmdLineTool.java:83)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at io.airlift.airline.ParserUtil.createInstance(ParserUtil.java:19)
    at io.airlift.airline.ParserUtil.createInstance(ParserUtil.java:37)
    at io.airlift.airline.Cli.parse(Cli.java:120)
    at io.airlift.airline.Cli.parse(Cli.java:97)
    at org.graylog2.bootstrap.Main.main(Main.java:57)
log4j:WARN No appenders could be found for logger (com.github.joschi.jadconfig.JadConfig).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

So, log4j doesn't find the needed classes (I think classes are located in graylog.jar). So how can I point log4j to this needed classes?

@kroepke kroepke added the bug label Mar 6, 2015

@kroepke kroepke added this to the 1.0.1 milestone Mar 6, 2015

@kroepke kroepke self-assigned this Mar 6, 2015

@kroepke

This comment has been minimized.

Member

kroepke commented Mar 6, 2015

@1tft until 1.0.1 is released which will fix this issue, please have a look at the class @joschi referred to, that is available in the stock log4j jar.

@1tft

This comment has been minimized.

1tft commented Mar 6, 2015

Hello, thank you for you prompt answer.
I changed the log4j.xml property file to the correct RollingFileAppender Class name and previous error has gone.
But now I get the following errors occured:
log4j:WARN Unrecognized element rollingPolicy
log4j:WARN Unrecognized element triggeringPolicy
log4j:WARN File option not set for appender [FILE].
log4j:WARN Are you using FileAppender instead of ConsoleAppender?
log4j:ERROR No output stream or file set for the appender named [FILE].

Changing name for "org.apache.log4j.FixedWindowRollingPolicy" and "org.apache.log4j.SizeBasedTriggeringPolicy" doesn't work. I coud not find these classes in graylog.jar file...
Do I have to wait till next release?

@kroepke

This comment has been minimized.

Member

kroepke commented Mar 6, 2015

The two RollingFileAppender classes are different versions, and thus take different parameters.
If you want to use the newer, improved one you will need to wait for Graylog 1.0.1.

In the meantime you can follow the examples at http://www.tutorialspoint.com/log4j/log4j_logging_files.htm to configure the older rolling appender.

@1tft

This comment has been minimized.

1tft commented Mar 6, 2015

Thank you very much for you support!

@kroepke kroepke closed this in 908ef06 Mar 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment