diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml index 1be340f01..7e18ae9b8 100644 --- a/.github/workflows/openapi.yml +++ b/.github/workflows/openapi.yml @@ -49,7 +49,7 @@ jobs: run: | cp rsc/application.properties.dist rsc/application.properties cp rsc/database.properties.dist rsc/database.properties - cp rsc/log4j.properties.dist rsc/log4j.properties + cp rsc/log4j2-spring.properties.dist rsc/log4j2-spring.properties cp rsc/settings.properties.dist rsc/settings.properties sed -e "s/JWT_TOKEN_SECRET/${{ steps.jwt.outputs.token }}/g" rsc/application.properties.dist > rsc/application.properties mvn install -DskipTests=true diff --git a/Makefile b/Makefile index 7afdd23d8..09964c094 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SHELL=/bin/bash # The name of the file to be modified OH_APPLICATION_PROPERTIES = ./rsc/application.properties OH_DATABASE_PROPERTIES = ./rsc/database.properties -OH_LOG4J_PROPERTIES = ./rsc/log4j.properties +OH_LOG4J_PROPERTIES = ./rsc/log4j2-spring.properties OH_SETTINGS = ./rsc/settings.properties .DEFAULT_GOAL = modify diff --git a/README.md b/README.md index bb6e74ae8..13bb33b73 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ For the moment, to build this project you should rsc/application.properties <- set a SHA-256 jwt token rsc/database.properties - rsc/log4j.properties + rsc/log4j2-spring.properties rsc/... 4. set target/rsc/database.properties diff --git a/rsc/log4j.properties.dist b/rsc/log4j.properties.dist deleted file mode 100644 index e057f651b..000000000 --- a/rsc/log4j.properties.dist +++ /dev/null @@ -1,25 +0,0 @@ -# default logger -log4j.rootLogger=INFO,RollingFile,StdOut - -# Null appender (off) -log4j.appender.null=org.apache.log4j.varia.NullAppender - -# StdOut Appender (with classes) (not used) -log4j.appender.StdOut = org.apache.log4j.ConsoleAppender -log4j.appender.StdOut.layout=org.apache.log4j.PatternLayout -log4j.appender.StdOut.layout.ConversionPattern=[%d{dd/MMM/yyyy HH:mm:ss}] [%X{OHUserGroup}:%X{OHUser}] %-p - %m%n - -# File Appender (with classes), daily rotation -log4j.appender.RollingFile = org.apache.log4j.DailyRollingFileAppender -log4j.appender.RollingFile.DatePattern='.'yyyy-MM-dd -log4j.appender.RollingFile.File=logs/openhospital-api.log -log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout -log4j.appender.RollingFile.layout.ConversionPattern=[%d{dd/MMM/yyyy HH:mm:ss}] [%X{OHUserGroup}:%X{OHUser}] %-p - %m (%l)%n - -# Assigning appenders to Open Hospital packages -log4j.logger.org.isf=INFO,RollingFile -log4j.additivity.org.isf = false - -# Assigning appenders to Spring packages -log4j.logger.org.springframework=DEBUG,RollingFile -log4j.additivity.org.springframework=true diff --git a/rsc/log4j2-spring.properties.dist b/rsc/log4j2-spring.properties.dist new file mode 100755 index 000000000..a16a10a80 --- /dev/null +++ b/rsc/log4j2-spring.properties.dist @@ -0,0 +1,58 @@ + +status = INFO +rootLogger.level = INFO +rootLogger.appenderRef.console.ref = STDOUT +rootLogger.appenderRef.rolling.ref = RollingFile + +# Direct log messages to STDOUT +appender.console.type = Console +appender.console.name = STDOUT +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = [%d{dd/MMM/yyyy HH:mm:ss}] [%X{OHUserGroup}:%X{OHUser}] %-p - %m%n + +# File Appender (with classes), daily rotation +appender.rolling.type = RollingFile +appender.rolling.name = RollingFile +appender.rolling.fileName= LOG_DEST/openhospital.log +appender.rolling.filePattern= LOG_DEST/openhospital.log.%d{yyyy-MM-dd} +appender.rolling.layout.type = PatternLayout +appender.rolling.layout.pattern = [%d{dd/MMM/yyyy HH:mm:ss}] [%X{OHUserGroup}:%X{OHUser}] %-p - %m (%l)%n +appender.rolling.policies.type = Policies +# To change log file every day +appender.rolling.policies.time.type = TimeBasedTriggeringPolicy +appender.rolling.policies.time.interval = 1 +appender.rolling.policies.time.modulate = true + + +# DB Appender (table columns) +appender.jdbc.type = JDBC +appender.jdbc.name = jdbc +appender.jdbc.connectionSource.driverClassName = com.mysql.cj.jdbc.Driver +appender.jdbc.connectionSource.type = DriverManager +appender.jdbc.connectionSource.connectionString = dbc:mysql://DBSERVER:DBPORT/DBNAME?autoReconnect=true +appender.jdbc.connectionSource.userName = DBUSER +appender.jdbc.connectionSource.password = DBPASS +appender.jdbc.tableName = logs +appender.jdbc.ignoreExceptions = false +appender.jdbc.columnConfigs[0].type = COLUMN +appender.jdbc.columnConfigs[0].name = LOG_TIME +appender.jdbc.columnConfigs[0].pattern = %d +appender.jdbc.columnConfigs[0].isUnicode = false +appender.jdbc.columnConfigs[1].type = COLUMN +appender.jdbc.columnConfigs[1].name = LOG_LEVEL +appender.jdbc.columnConfigs[1].pattern = %5p +appender.jdbc.columnConfigs[1].isUnicode = false +appender.jdbc.columnConfigs[2].type = COLUMN +appender.jdbc.columnConfigs[2].name = MESSAGE +appender.jdbc.columnConfigs[2].pattern = %mm%ex%n +appender.jdbc.columnConfigs[2].isUnicode = false + + +# Assigning appenders to Hibernate packages (DB loggers) +# - hibernate.SQL to DEBUG for SQL queries to be logged +# - hibernate.type to TRACE for queries parameters to be logged with "binding parameter [?]" +##logger.hibernate-SQL.name=org.hibernate.SQL +##logger.hibernate-SQL.level=DEBUG +## +##logger.hibernate-type.name=org.hibernate.type +##logger.hibernate-type.level=TRACE