Stacktrace gets lost in the log file


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:

class CustomException extends GradleScriptException {
  public CustomException(String message, Throwable cause=null) {
    super(message, cause);

log4j config xml:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30" status="error" >
    <Property name="log-path">log</Property>
    <Property name="log-pattern">%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n</Property>
    <Console name="StdOut" target="SYSTEM_OUT">
      <PatternLayout pattern="${log-pattern}"/>
    <RollingFile name="RollingFile" fileName="${log-path}/update.log"
    filePattern="${log-path}/update-%d{yyyy-MM-dd}-%i.log" >
      <PatternLayout pattern="${log-pattern}"/>
        <SizeBasedTriggeringPolicy size="1 MB" />
      <DefaultRolloverStrategy max="10"/>
    <Root level="info" additivity="false">
      <AppenderRef ref="StdOut"/>
      <AppenderRef ref="RollingFile"/>
    <Logger name="com.sowatec" level="debug" additivity="false">
      <AppenderRef ref="StdOut"/>
      <AppenderRef ref="RollingFile"/>