Make remote poller logging configurable by file
Description
Acceptance / Success Criteria
Attachments
is duplicated by
Lucidchart Diagrams
Activity

Seth Leger August 15, 2013 at 12:56 PM
We need to redo the patch in light of the recent switch to slf4j (which delegates to log4j2). The remote poller logging now goes to stdout and the configuration is stored in the remote poller JAR. Here is the location in the source tree:

Alexander Hoogerhuis July 30, 2012 at 8:18 PM
I've got a patch here to clean up and this should be able to work more sensibly, I'm just delayed by two rounds of pneumonia.

Alexander Hoogerhuis May 14, 2012 at 5:52 PM
New version, does things more tidy, has support for -4, --log4j param to tell it where to find log config, also makes the opennms.poller.configuration.resource prop follow poller.home, not user.home.

Alexander Hoogerhuis May 13, 2012 at 12:47 AM
The patch added makes the remote poller look for the system properties poller.logfile and log4j.properties. If poller.logfile it will log with the default format and fixed INFO level, etcas specified in LogUtils.java, if log4j.properties is specified and points to a valid log4j-config it will read the config from that file. The part re poller.logfile is also the same patch that is in the other issue to make it easier to run multiple remote pollers on the same machine.
Neither option change the default behaviour nor interfere with the shell script that is bundled.

Alexander Hoogerhuis May 13, 2012 at 12:45 AM
Make the remote poller log more sensibly
This is the code that initialises the logging in the remote poller, from ./core/lib/src/main/java/org/opennms/core/utils/LogUtils.java:
public static void logToFile(final String file) {
final Properties logConfig = new Properties();
logConfig.setProperty("log4j.reset", "true");
logConfig.setProperty("log4j.rootCategory", "INFO, FILE");
logConfig.setProperty("log4j.appender.FILE", "org.apache.log4j.RollingFileAppender");
logConfig.setProperty("log4j.appender.FILE.MaxFileSize", "100MB");
logConfig.setProperty("log4j.appender.FILE.MaxBackupIndex", "4");
logConfig.setProperty("log4j.appender.FILE.File", file);
logConfig.setProperty("log4j.appender.FILE.layout", "org.apache.log4j.PatternLayout");
logConfig.setProperty("log4j.appender.FILE.layout.ConversionPattern", "%d %-5p [%t] %c: %m%n");
PropertyConfigurator.configure(logConfig);
}
It's called from ./features/remote-poller/src/main/java/org/opennms/poller/remote/Main.java:
if (Boolean.getBoolean("debug")) {
LogUtils.logToConsole();
} else {
LogUtils.logToFile(logFile);
}
Shouldnt this be able to read System.getProperty("poller.config") or some such to tell it where a log4j.properties file might be with some sensible defaults?