cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configure Rollingfile loggers in log4j2.properties

Configure Rollingfile loggers in log4j2.properties

Below is how we can enable RollingFile loggers in log4j2

 

## Default Appender ##
appender.rolling.type=RollingFile
appender.rolling.name=IIQRFile
appender.rolling.fileName=C:/SailpointLogs/sailpoint.log
appender.rolling.filePattern=C:/SailpointLogs/sailpoint-%d{yyyy-MM-dd}-%i.log.gz
appender.rolling.layout.type=PatternLayout
## OOTB pattern is '%d{ISO8601} %5p %t %c{4}:%L - %m%n' ##
appender.rolling.layout.pattern=%d{DEFAULT} %5p %t %c{4}:%L - %m%n
appender.rolling.policies.type=Policies
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=200MB
appender.rolling.strategy.type=DefaultRolloverStrategy
appender.rolling.strategy.max=15

## Same as Default Appender, we will use this appender in case where we need the logs generated sperately from the default loggger appender IIQRFile ##
appender.specificFile.type=RollingFile
appender.specificFile.name=IIQSpecificFile
appender.specificFile.fileName=C:/SailpointLogs/Specific/specific.log
appender.specificFile.filePattern=C:/SailpointLogs/Specific/specific-%d{yyyy-MM-dd}-%i.log.gz
appender.specificFile.layout.type=PatternLayout
appender.specificFile.layout.pattern=%d{DEFAULT} %5p %t %c{4}:%L - %m%n
appender.specificFile.policies.type=Policies
appender.specificFile.policies.size.type=SizeBasedTriggeringPolicy
appender.specificFile.policies.size.size=200MB
appender.specificFile.strategy.type=DefaultRolloverStrategy
appender.specificFile.strategy.max=15

## Sailpoint Console Appender same as default, this will be used to log console ##
appender.consoleFile.type=RollingFile
appender.consoleFile.name=IIQConsoleFile
appender.consoleFile.fileName=C:/SailpointLogs/SailpointConsole/console.log.gz
appender.consoleFile.filePattern=C:/SailpointLogs/SailpointConsole/console-%d{yyyy-MM-dd}-%i.log
appender.consoleFile.layout.type=PatternLayout
appender.consoleFile.layout.pattern=%d{DEFAULT} %5p %t %c{4}:%L - %m%n
appender.consoleFile.policies.type=Policies
appender.consoleFile.policies.size.type=SizeBasedTriggeringPolicy
appender.consoleFile.policies.size.size=200MB
appender.consoleFile.strategy.type=DefaultRolloverStrategy
appender.consoleFile.strategy.max=15

 

Below appender can be added if we need to have a separate logger that will only logs error 

 

## Error Only Appender ##
appender.error.type=RollingFile
appender.error.name=IIQErrorFile
appender.error.fileName=C:/SailpointLogs/Error/error.log
appender.error.filePattern=C:/SailpointLogs/Error/error-%d{yyyy-MM-dd}-%i.log
appender.error.layout.type=PatternLayout
appender.error.layout.pattern=%d{DEFAULT} %5p %t %c{4}:%L - %m%n
appender.error.policies.type=Policies
appender.error.policies.size.type=SizeBasedTriggeringPolicy
appender.error.policies.size.size=200MB
appender.error.strategy.type=DefaultRolloverStrategy
appender.error.strategy.max=15
appender.error.filter.threshold.type=LevelRangeFilter
appender.error.filter.threshold.minLevel=error
appender.error.filter.threshold.maxLevel=error

 

Now after listing all the appenders, below is how you have to add the entries in the rootLogger to work with all your appenders

 

#######################################
## rootLogger specify all appender rollings used by your log4j2
#######################################

rootLogger.level=warn
## Only appenderRef that has been used in log4j2, Here we are using all that are part of this example ##
rootLogger.appenderRefs=IIQRFile,IIQErrorFile,IIQSpecificFile,IIQConsoleFile
rootLogger.appenderRef.stdout.ref=stdout

## Specify the default appenderRef and error appenderRef to automate logging ##
rootLogger.appenderRef.rolling.ref=IIQRFile

## To log errors by default ##
rootLogger.appenderRef.error.ref=IIQErrorFile

 

Below is how we will enable IIQ console logger in IIQConsoleFile appender

 

#######################################
## SailPoint Console loggers iiq.bat console
#######################################

logger.spConsole.name=sailpoint.server.SailPointConsole
logger.spConsole.level=all
## remove the below 2 lines if you want to log in default IIQRFile appender ##
logger.spConsole.additivity=false
logger.spConsole.appenderRef.connector.ref=IIQConsoleFile

 

Below is how you will log to your default appender IIQRFile

 

logger.orgSpringframework.name=org.springframework
logger.orgSpringframework.level=info

 

Below is how you can log to your appender IIQSpecificFile in special cases

 

logger.ObjectConfig.name=sailpoint.object.ObjectConfig
logger.ObjectConfig.level=trace
logger.ObjectConfig.additivity=false
logger.ObjectConfig.appenderRef.connector.ref=IIQSpecificFile

 

Disable Heartbeat logger

 

## Disable Heartbeat logger ##
logger.heartbeat.name=sailpoint.server.HeartbeatService
logger.heartbeat.level=off

 

 

Labels (2)
Comments

This is what we have now and it is working well.

appender.RollingFile.type = RollingFile
appender.RollingFile.name = file
appender.RollingFile.fileName=/opt/tomcat/apache-tomcat-9.0.34/logs/sailpoint.log
appender.RollingFile.filePattern = /opt/tomcat/apache-tomcat-9.0.34/logs/sailpoint.%d{dd-MMM}.log.gz
appender.RollingFile.layout.type = PatternLayout
appender.RollingFile.layout.pattern = %d{ISO8601} %5p %t %c{4}:%L - %m%n
appender.RollingFile.policies.type = Policies
appender.RollingFile.policies.size.type = SizeBasedTriggeringPolicy
appender.RollingFile.policies.size.size=100MB
appender.RollingFile.strategy.type = DefaultRolloverStrategy
appender.RollingFile.strategy.max = 20

Hi @SurajChauhan ,

Please check the below comment for a working version of log4j2.

https://community.sailpoint.com/t5/IdentityIQ-Wiki/Configure-RollingFile-Loggers-in-log4j2-propertie...

 

Thanks,

Gaurav Khandelwal

With below entries in  log4j2 properties, log files are not getting updated. ( in Unix machine)

 

######################################
## Global log4j2 properties
######################################
name=identityiq_default
status=warn
monitorInterval=20
packages=sailpoint.api.logging

#######################################
## Appenders
#######################################

### direct log messages to stdout ###
appender.stdout.type=Console
appender.stdout.name=stdout
appender.stdout.target=SYSTEM_OUT
appender.stdout.layout.type=PatternLayout
appender.stdout.layout.pattern=%d{ISO8601} %5p %t %c{4}:%L - %m%n

### direct log messages to the db
appender.syslog.type=spsyslog
appender.syslog.name=spsyslog

# Below is an example of how to create a logger that writes to a file.
# Uncomment the following five lines, then uncomment the
# rootLogger.appenderRef.file.ref definition below
appender.file.type=File
appender.file.name=file
appender.file.fileName=/opt/app/iiq/sailpoint.log
appender.file.layout.type=PatternLayout
appender.file.layout.pattern=%d{ISO8601} %5p %t %c{4}:%L - %m%n

#######################################
## rootLogger
#######################################

### set default log levels and appenderRef
### valid log levels in increasing order of severity are:
### trace, debug, info, warn, error, fatal, off
### trace is required to get method entry and exit logging

rootLogger.level=trace
rootLogger.appenderRef.stdout.ref=file

# Uncomment to also write to file appender by default.
# Also need to uncomment the file appender definition above.
rootLogger.appenderRef.file.ref=file

 

Can some one let me know where we are going wrong.

Version history
Revision #:
5 of 5
Last update:
‎Feb 23, 2023 11:51 AM
Updated by: