Class CmsLog
- java.lang.Object
-
- org.opencms.main.CmsLog
-
public final class CmsLog extends java.lang.Object
Provides the OpenCms logging mechanism.The OpenCms logging mechanism is based on Apache Commons Logging. However, log4j is shipped with OpenCms and assumed to be used as default logging mechanism. Since apparently Commons Logging may cause issues in more complex classloader scenarios, we may switch the logging interface to log4j
UGLI
once the final release is available.The log4j configuration file shipped with OpenCms is located in
${opencms.WEB-INF}/classes/log4j2.xml
. OpenCms will auto-configure itself to write it's log file to${opencms.WEB-INF}/logs/opencms.log
. This default behaviour can be supressed by either using a log4j configuration file from another location, or by setting the special property${opencms.set.logfile}
in the log4j configuration file tofalse
.- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FILE_LOG
The name of the opencms.log file.static java.lang.String
FOLDER_LOGS
Path to the "logs" folder relative to the "WEB-INF" directory of the application.static org.apache.commons.logging.Log
INIT
Log for initialization messages.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
eval(org.apache.commons.logging.Log log, java.util.concurrent.Callable<java.lang.String> stringProvider)
Helper for safely evaluating lambda functions to produce log output and catch exceptions they might throw.static org.apache.commons.logging.Log
getLog(java.lang.Object obj)
Returns the log for the selected object.protected static java.lang.String
getLogFileRfsPath()
Returns the filename of the log file (in the "real" file system).static boolean
isManageable(java.lang.String channel)
Checks whether a log channel should be manageable through the GUI.static void
makeChannelNonManageable(java.lang.String channel)
Adds a log channel that should not be manageable via the GUI.static java.lang.String[]
render(java.lang.Throwable throwable)
Render throwable using Throwable.printStackTrace.
-
-
-
Field Detail
-
FILE_LOG
public static final java.lang.String FILE_LOG
The name of the opencms.log file.- See Also:
- Constant Field Values
-
FOLDER_LOGS
public static final java.lang.String FOLDER_LOGS
Path to the "logs" folder relative to the "WEB-INF" directory of the application.
-
INIT
public static org.apache.commons.logging.Log INIT
Log for initialization messages.
-
-
Method Detail
-
eval
public static java.lang.String eval(org.apache.commons.logging.Log log, java.util.concurrent.Callable<java.lang.String> stringProvider)
Helper for safely evaluating lambda functions to produce log output and catch exceptions they might throw.- Parameters:
log
- the logger to use for logging errorsstringProvider
- the string provider (normally just given as a lambda function)- Returns:
- the result of the function (or <ERROR> if an exception was thrown)
-
getLog
public static org.apache.commons.logging.Log getLog(java.lang.Object obj)
Returns the log for the selected object.If the provided object is a String, this String will be used as channel name. Otherwise the objects class name will be used as channel name.
- Parameters:
obj
- the object channel to use- Returns:
- the log for the selected object channel
-
isManageable
public static boolean isManageable(java.lang.String channel)
Checks whether a log channel should be manageable through the GUI.- Parameters:
channel
- the name of the channel- Returns:
- true if the channel should be manageable through the GUI
-
makeChannelNonManageable
public static void makeChannelNonManageable(java.lang.String channel)
Adds a log channel that should not be manageable via the GUI.- Parameters:
channel
- the channel to add
-
render
public static java.lang.String[] render(java.lang.Throwable throwable)
Render throwable using Throwable.printStackTrace.This code copy from "org.apache.log4j.DefaultThrowableRenderer.render(Throwable throwable)"
- Parameters:
throwable
- throwable, may not be null.- Returns:
- string representation.
-
getLogFileRfsPath
protected static java.lang.String getLogFileRfsPath()
Returns the filename of the log file (in the "real" file system).If the method returns
null
, this means that the log file is not managed by OpenCms.- Returns:
- the filename of the log file (in the "real" file system)
-
-