Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
OP-1239: re-enable logging to a physical file (informatici#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbmalkovsky authored May 22, 2024
1 parent 55f7095 commit 0dab980
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 0 additions & 25 deletions rsc/log4j.properties.dist

This file was deleted.

58 changes: 58 additions & 0 deletions rsc/log4j2-spring.properties.dist
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0dab980

Please sign in to comment.