Hi,
im using log4j and most of my exceptions are customized.
If I get an error, the custom error msg is printed to the console and log file. So far so good.
But if i run the gradle script with the --stacktrace parameter it only writes the stacktrace to the console, not to my log file.
The idea is to redirect the entire system.err to the logfile. Any Idea what I am missing?
Thanks for reading.
Call of custom exception:
throw new CustomException("Execution cancelled by user")
Exception class:
@Log4j2
class CustomException extends GradleScriptException {
public CustomException(String message, Throwable cause=null) {
super(message, cause);
log.error(message)
}
}
log4j config xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30" status="error" >
<Properties>
<Property name="log-path">log</Property>
<Property name="log-pattern">%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n</Property>
</Properties>
<Appenders>
<Console name="StdOut" target="SYSTEM_OUT">
<PatternLayout pattern="${log-pattern}"/>
</Console>
<RollingFile name="RollingFile" fileName="${log-path}/update.log"
filePattern="${log-path}/update-%d{yyyy-MM-dd}-%i.log" >
<PatternLayout pattern="${log-pattern}"/>
<Policies>
<SizeBasedTriggeringPolicy size="1 MB" />
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info" additivity="false">
<AppenderRef ref="StdOut"/>
<AppenderRef ref="RollingFile"/>
</Root>
<Logger name="com.sowatec" level="debug" additivity="false">
<AppenderRef ref="StdOut"/>
<AppenderRef ref="RollingFile"/>
</Logger>
</Loggers>
</Configuration>