Skip to content

Commit

Permalink
use separate cli-log4j.properties log4j config for cli tools
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Apr 19, 2016
1 parent 20ad30b commit cb64a12
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/com/dtolabs/launcher/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void main(final String args[]) {
"admin.aclpolicy",
"apitoken.aclpolicy",
"framework.properties",
"log4j.properties",
"cli-log4j.properties",
"profile.bat",
"profile",
"project.properties"
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/com/dtolabs/rundeck/core/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public final class Constants {

// java.home
public static final String JAVA_HOME = System.getProperty("java.home");
public static final String CLI_LOG4J_PROPERTIES = System.getProperty("rundeck.cli.log4j.config",
"cli-log4j.properties");

/**
* @return RDECK_BASE, base directory patch for instance of client, equivalent to ${rdeck.base}
Expand Down Expand Up @@ -94,7 +96,7 @@ public static String getFrameworkProperties(final String rdeck_base) {
* @param rdeck_base Ctl Base directory
*/
public static String getLog4jProperties(final String rdeck_base) {
return getFrameworkConfigDir(rdeck_base) + FILE_SEP + "log4j.properties";
return getFrameworkConfigDir(rdeck_base) + FILE_SEP + CLI_LOG4J_PROPERTIES;
}

public static String getLog4jProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private Option getOption(final String opt) {
* @throws CLIToolException if an error occurs
*/
public void run(final String[] args) throws CLIToolException {
PropertyConfigurator.configure(Constants.getLog4jProperties(Constants.getSystemBaseDir()));
PropertyConfigurator.configure(Constants.getLog4jPropertiesFile().getAbsolutePath());
CommandLine cli = parseArgs(args);
validateOptions(cli,args);
go();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,7 @@ protected static NodeSet createNodeSet(final Map includeMap, final Map excludeMa
* @throws Exception on error
*/
public static void main(final String[] args) throws Exception {

/**
* Initialize the log4j logger
*/
File configDir = Constants.getFrameworkConfigFile();
PropertyConfigurator.configure(new File(configDir,
"log4j.properties").getAbsolutePath());
PropertyConfigurator.configure(Constants.getLog4jPropertiesFile().getAbsolutePath());
final ExecTool ExecTool = new ExecTool( BaseTool.createDefaultDispatcherConfig());
ExecTool.shouldExit = true;
ExecTool.run(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ public String getName() {
* @throws Exception action error
*/
public static void main(final String[] args) throws Exception {
PropertyConfigurator.configure(new File(Constants.getFrameworkConfigFile(),
"log4j.properties").getAbsolutePath());
PropertyConfigurator.configure(Constants.getLog4jPropertiesFile().getAbsolutePath());
final JobsTool tool = new JobsTool(createDefaultDispatcherConfig(),new DefaultCLIToolLogger());
tool.setShouldExit(true);
int exitCode = 1; //pessimistic initial value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public ProjectTool(final DispatcherConfig config,final File baseDir) {
/**
* Initialize the log4j logger
*/
PropertyConfigurator.configure(new File(Constants.getLog4jProperties(baseDir.getAbsolutePath()))
.getAbsolutePath());
PropertyConfigurator.configure(Constants.getLog4jPropertiesFile().getAbsolutePath());
frameworkProperties = FrameworkFactory.createFilesystemFramework(baseDir).getPropertyLookup();
dispatcher = FrameworkFactory.createDispatcher(config);
extraProperties = new Properties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,3 @@ log4j.appender.file.datePattern='.'yyyy-MM-dd
log4j.appender.file.append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c - %m%n

#
# Disable h2database logging
# workaround for issue https://github.com/rundeck/rundeck/issues/1175
log4j.logger.h2database = off
29 changes: 29 additions & 0 deletions packaging/debroot/etc/rundeck/cli-log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
#
log4j.rootCategory=INFO, file

#
# stdout - ConsoleAppender
#
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}: %m%n

#
# plainStdout - ConsoleAppender which
# doesnt provide any timestamps, etc
#
log4j.appender.plainStdout=org.apache.log4j.ConsoleAppender
log4j.appender.plainStdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.plainStdout.ConversionPattern=%m%n


#
# file - DailyRollingFileAppender
#
#log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.file=rundeck-cli.log
#log4j.appender.file.datePattern='.'yyyy-MM-dd
#log4j.appender.file.append=true
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c - %m%n
29 changes: 29 additions & 0 deletions packaging/root/etc/rundeck/cli-log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
#
log4j.rootCategory=INFO, file

#
# stdout - ConsoleAppender
#
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p %c{1}: %m%n

#
# plainStdout - ConsoleAppender which
# doesnt provide any timestamps, etc
#
log4j.appender.plainStdout=org.apache.log4j.ConsoleAppender
log4j.appender.plainStdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.plainStdout.ConversionPattern=%m%n


#
# file - DailyRollingFileAppender
#
#log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.file=rundeck-cli.log
#log4j.appender.file.datePattern='.'yyyy-MM-dd
#log4j.appender.file.append=true
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c - %m%n
1 change: 1 addition & 0 deletions packaging/rundeck.spec
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ getent passwd rundeck >/dev/null || useradd -d /var/lib/rundeck -m -g rundeck ru
%config(noreplace) /etc/rundeck/admin.aclpolicy
%config(noreplace) /etc/rundeck/apitoken.aclpolicy
%config(noreplace) /etc/rundeck/log4j.properties
%config(noreplace) /etc/rundeck/cli-log4j.properties
%config(noreplace) /etc/rundeck/profile
%config(noreplace) /etc/rundeck/project.properties

Expand Down

0 comments on commit cb64a12

Please sign in to comment.