Successfully!

Error!

You are viewing 10.0 help doc. More details are displayed in the latest help doc

fanruan.log Output Logic Introduction

I. Overview

After finereport is deployed, it will generate the operation log of fanruan.log. This file records the information of daily execution output and throws error information when exception occurs. 

Sometimes customers cannot find fanruan.log, which makes it impossible to find the cause of the error.

II. Log Logic

1. Log location logic

1) Report Server

The log location is determined according to log4j.properties at server startup.

2) Report Designer

Click designer.exe to start, logs are located in the same directory as bin


2. Log execution logic

System first reads the built-in configuration of FineReport, located in fine-core.jar#com/fr/general/log/log4j.properties

After loading the built-in configuration, it reads whether the custom configuration file exists in webapps/appName/WEB-INF/ config/log4j.properties;

If it exists, it overrides the FineReport built-in configuration and loads the custom configuration.

III. Change fanruan.log output location

1. Use built-in configuration

  • ${LOG_ROOT_LEVEL}:Set the minimum level of log,the values that can be set are OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL or custom levels. Log4j recommends only using four levels of ERROR, WARN, INFO, and DEBUG.

  • standardappenderName ,Location of the log file.

  • stdout:Output to console.

  • log4j.appender.standard.File:Specific folder location.

  • ${LOG_HOME}The path of LOG_HOME is obtained through the system variable user.dir, and the location of user.dir is the location where the script is executed. Generally, we can get the actual user.dir of the corresponding process by executing the command: jcmd pid VM.system_properties.

Note:

WindowsLinux
The decompressed version of tomcat (such as Server Deployment Package), usually when we start tomcat, we go to tomcat/bin and double-click startup.bat to start, so user.dir is tomcat/bin, so the log will be output to tomcat/ under logs.Linux usually executes startup.bat to start tomcat, but some users will not switch to the bin directory for execution, and may execute it in a directory outside Tomcat, so the user.dir is different, which leads to the log output. The locations also vary.

If it is an installed version of tomcat (registered as a system service), it will be found through testing that user.dir is actually the path of the tomcat folder itself.

So the log will be output to the logs of the same level in the tomcat folder.

image.png

2. Use custom configuration file

Usually the report project is deployed to the server, and we want to output the fanruan.log to a fixed folder.

At this time, we can customize the log4j.properties and place it in the webapps/APPName/WEB-INF/config folder.

The content of the file can be copied and modified the built-in log4j.properties, just modify log4j.appender.standard.File

log4j.appender.standard.File=/users/fanruan/tomcat/logs/fanruan.log

Full code:

log4j.rootLogger=${LOG_ROOT_LEVEL},standard,stdout
log4j.appender.standard=com.fr.third.apache.log4j.DailyRollingFileAppender
log4j.appender.standard.DatePattern='.'yyyy-MM-dd
log4j.appender.standard.File=/users/fanruan/tomcat/logs/fanruan.log
#log4j.appender.standard.layout=com.fr.third.apache.log4j.PatternLayout
log4j.appender.standard.layout=com.fr.general.log.FinePatternLayout
# %d{yyyy/MM/dd HH:mm:ss} Specify date format
log4j.appender.standard.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %t %p [%c]${EXTRA}%m%n
log4j.appender.standard.Append=true
# maxBackupIndex Combined with DailyMaxRollingFileAppender and it takes effect when it is a positive integer,
# it means to keep log files for several days.
# log4j.appender.standard=com.fr.general.log.appender.DailyMaxRollingFileAppender
# log4j.appender.standard.maxBackupIndex=30

log4j.appender.stdout=com.fr.third.apache.log4j.ConsoleAppender
#log4j.appender.stdout.layout=com.fr.third.apache.log4j.PatternLayout
log4j.appender.stdout.layout=com.fr.general.log.FinePatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %t %p [%c]${EXTRA}%m%n
log4j.appender.stdout.filter.ConsoleLogFilter=com.fr.general.log.ConsoleLogFilter

log4j.logger.com.fr.third.org.hibernate=ERROR
log4j.logger.com.fr.log.throwable.stack.depth=-1

Note:After the fanruan.log is changed, it needs to be restarted to be automatically generated.

Attachment List


Theme: Decision-making Platform
Already the First
Already the Last
  • Helpful
  • Not helpful
  • Only read

Doc Feedback