Introduced:
This article focuses on a quick study of the log system used by OpenCms and the respective logs.
Analysis:
(1) Log when installing OpenCms
Because the Setup.bat in the $catalina_home/opencms/web-inf directory is automatically called when the OpenCms is installed (setup.sh if it is a UNIX machine)
And in this execution script, the actual execution of the command is configured to be
... rem set standard command for invoking Java.set _runjava= "%java_home%\bin\java.exe" set mainclass= Org.opencms.setup.cmsautosetup...rem Execute opencms%_runjava%%java_opts%-classpath "%opencms_home%\classes% classpath%%opencms_cp%%tomcat_lib% "%mainclass%%cmd_line_args%
So, it actually executes the Cmsautosetup class, and this execution wizard is actually done by Cmsautosetupbean:
Public Cmsautosetup (cmsautosetupproperties props) {m_props = props; M_bean = new Cmssetupbean (); M_bean.init (Props.getsetupwebapppath (), props.getserveltmapping (), Props.getsetupdefaultwebappname ()); }
The log file location in the Setup Wizard is defined in Cmsautosetupbean:
/** location for log file. */protected String M_logfile = cmssysteminfo.folder_webinf + cmslog.folder_logs + "Setup.log"; /** location for logs relative to the WebApp folder. */protected String M_logsfolder = Cmssysteminfo.folder_webinf + cmslog.folder_logs;
It can be seen that the location of this m_logfile is Setup.log under the $CATALINA _home/webapps/opencms/web-inf/logs directory.
(2) Log at runtime
Because the Org.opencms.main.OpenCms class provides the runtime of the OpenCms system, its Getlog () method invokes the static method Getlog () method of the Cmslog class. We looked at the Cmslog class and found the following code in its static initial block:
/** * initializes the opencms logger configuration .<p> */ static { try { // look for the log4j.properties that shipped with opencms url url = loader.getresource (" Log4j.properties "); if (url ! = null) { // found some log4j properties, let ' S see if these are the ones used by OpenCms &nBsp String path = cmsfileutil.normalizepath (url, '/'); // in a default OpenCms configuration, the following path would point to the opencms " Web-inf " folder string webinfpath = cmsresource.getparentfolder (Cmsresource.getfolderpath (path)); // check for the opencms configuration file // check for the opencms tld file String Tldfilepath = webinfpath + cmssysteminfo.file_tld; file tldfile = new file (Tldfilepath); if (Tldfile.exists ()) { // assume this is a default opencms log configuration Cmsparameterconfiguration configuration = new cmsparameterconfiguration (PATH); // check if opencms should set the log file environment variable boolean setlogfile = configuration.getboolean ("Opencms.set.logfile", false); if (SetLogFile) { // set "Opencms.log" variable string logfilepath = cmsfileutil.normalizepath (webInfPath + FOLDER_LOGS + FILE_LOG, '/'); file logfile = new file ( LogFilePath); m_logfilerfspath = logfile.getabsolutepath (); m_logfilerfsfolder = cmsfileutil.normalizepath (LogFile.getParent () + '/', file.separatorchar); system.setproperty (" Opencms.logfile ", m_logfilerfspath); system.setproperty (" Opencms.logfolder ", m_logfilerfsfolder); // re-read the configuration with the new environment variable available propertyconfigurator.configure ( Path); } } // can ' T localize this message since this would end in an endless logger init loop inIt.info (". log4j config file : " + path); &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP, ..... }
This means that it checks for the value of key opencms.set.logfile in the config file log4j.properties, and if true, sets the log file at runtime to web-inf/ The Opencms.log file under the logs directory.
This switch has been set to true in Log4j.properties:
# OPENCMS provides a special variable ${opencms.logfile} to the environment, which contains# the log file path. The location of this file was calculated relative to this # "log4j.properties" file on OpenCms startup. If This file is located in the folder "${classes}", and then the log was written to "${classes}". /logs/opencms.log ". # To disable the mechanism, you must set ${opencms.set.logfile} to "false". In this case # You must configure the log output file Manually.opencms.set.logfile=true
So we understand that the runtime log, all exist in the $catalina_home/webapps/opencms/web-inf/logs directory of the Opencms.log.
This article is from the "cohesion of parallel Lines" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1587167
OpenCms Log Study