NSD1418 Configure OTP Server with daily rolling of log files
Fact
- Nordic Edge One Time Password Server
Situation
The OTP Server uses LOG4J as logging API.
Make the OTP Server roll log files on a daily basis.
Solution
Create a file called log4j.properties in the root folder of OTP Server:
This will override OTP Servers normal log-handling.
Add a log4j appender for the OTPServer logging and other appenders as you like.
You can log to syslog and file at the same time.
Example of log4j.properties with daily rolling (at midnight) for OTPServer log:
log4j.rootLogger=INFO
##########################################
## OTP SERVER LOG TO FILE ON A DAILY BASIS
##########################################
log4j.appender.DAILY=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DAILY.File=logs/otpserverdaily.log
log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd
log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout
log4j.appender.DAILY.layout.conversionPattern=%d{ISO8601}: %p: %m%n
log4j.logger.otp.se.nordicedge=INFO, DAILY
In the example above we use log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd
This will copy the contents of logs/otpserverdaily.log to logs/otpserverdaily.log.2012-01-30 (presuming the date is january 30 2012) and on 31 of january continue logging in logs/otpserverdaily.log
Variants of the DatePattern
You can configure log4j to roll files with
| Value | Description |
| '.'yyyy-MM | Rollover at the beginning of each month.
Format: logs/otpserverdaily.log.2012-01 |
| '.'yyyy-ww | Rollover at the first day of each week. The first day of the week depends on the locale.
Format: logs/otpserverdaily.log.2012-23 |
| '.'yyyy-MM-dd | Rollover at midnight each day.
Format: logs/otpserverdaily.log.2012-01-30 |
| '.'yyyy-MM-dd-a | Rollover at midnight and midday of each day.
Format: logs/otpserverdaily.log.2012-01-30-AM |
| '.'yyyy-MM-dd-HH | Rollover at the top of every hour.
Format: logs/otpserverdaily.log.2012-01-30-10 |
| '.'yyyy-MM-dd-HH-mm | Rollover at the beginning of every minute.
Format: logs/otpserverdaily.log.2012-01-30-09-51 |
For more information on LOG4J please visit: http://projects.apache.org/projects/log4j.html
Disclaimer
The origin of this information may be internal or external to Nordic Edge™. Nordic Edge™ makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Nordic Edge™ makes no explicit or implied claims to the validity of this information. Any trademarks referenced in this document are the property of their respective owners.
Nordic Edge Support – www.nordicedge.se
