Skip to content

Commit

Permalink
LDEV-3420 Allow overriding log defaults, i.e. force logs to console
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Feb 1, 2025
1 parent 9e6618f commit cde5d82
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ public final class ConfigWebFactory extends ConfigFactory {
public static final boolean LOG = true;
private static final int DEFAULT_MAX_CONNECTION = 100;
public static final String DEFAULT_LOCATION = Constants.DEFAULT_UPDATE_URL.toExternalForm();
private static String forceLogAppender = SystemUtil.getSystemPropOrEnvVar("lucee.logging.force.appender", null);
private static String forceLogLevel = SystemUtil.getSystemPropOrEnvVar("lucee.logging.force.level", null);


/**
* creates a new ServletConfig Impl Object
Expand Down Expand Up @@ -2152,7 +2155,9 @@ else if (hasCS) {
name = entry.getKey().getString();

// appender
cdAppender = getClassDefinition(child, "appender", config.getIdentification());
if (forceLogAppender != null) cdAppender = config.getLogEngine().appenderClassDefintion(forceLogAppender);
else cdAppender = getClassDefinition(child, "appender", config.getIdentification());

if (!cdAppender.hasClass()) {
tmp = StringUtil.trim(getAttr(child, "appender"), "");
cdAppender = config.getLogEngine().appenderClassDefintion(tmp);
Expand All @@ -2174,6 +2179,7 @@ else if (!cdLayout.isBundle()) {
layoutArgs = toArguments(child, "layoutArguments", true, false);

String strLevel = getAttr(child, "level");
if (forceLogLevel !=null) strLevel = forceLogLevel;
if (StringUtil.isEmpty(strLevel, true)) strLevel = getAttr(child, "logLevel");
level = LogUtil.toLevel(StringUtil.trim(strLevel, ""), Log.LEVEL_ERROR);
readOnly = Caster.toBooleanValue(getAttr(child, "readOnly"), false);
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/resource/setting/sysprop-envvar.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,5 +408,15 @@
"sysprop": "lucee.debugging.maxPageParts",
"envvar": "LUCEE_DEBUGGING_MAXPAGEPARTS",
"desc": "Maximum number of debugging page parts (executionLogs to output), 0 to disable max limit"
},
{
"sysprop": "lucee.logging.force.appender",
"envvar": "LUCEE_LOGGING_FORCE_APPENDER",
"desc": "If set, override the default log4j appender, which is usually resource (log files), use console to log all logs to console"
},
{
"sysprop": "lucee.logging.force.level",
"envvar": "LUCEE_LOGGING_FORCE_LEVEL",
"desc": "If set, override the default log4j log level for all logs, which is usually ERROR"
}
]
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.2.0.309-SNAPSHOT"/>
<property name="version" value="6.2.0.310-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.2.0.309-SNAPSHOT</version>
<version>6.2.0.310-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down
5 changes: 4 additions & 1 deletion test/run-tests.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ try {
logsDir = configDir & server.separator.file & "logs";
deployLog = logsDir & server.separator.file & "deploy.log";
//dump(deployLog);
content = fileRead( deployLog );
if ( fileExists( deployLog ) )
content = fileRead( deployLog );
else
content = "deploy.log not found, is logging redirected to console?";
systemOutput("-------------- Deploy.Log ------------",true);
systemOutput( content, true );
Expand Down

0 comments on commit cde5d82

Please sign in to comment.