## Logback error messages and their meanings

The contextSelector cannot be null in `StaticLoggerBinder`.

An `IllegalStateException` is thrown when no ContextSelector could be set for logback's `StaticLoggerBinder`. In principle, this error can only occur when the context selector is expressly specified by the user, and when that context selector cannot not be instantiated correctly.

It should not happen when you are using the default or JNDI context selectors.

This appender no longer admits a layout as a sub-component, set an encoder instead.

As of logback version 0.9.19, the `WriterAppender` class has been renamed as `OutputStreamAppender`, with `FileAppender` now sub-classing the latter. `OutputStreamAppender` and sub-classes now take an `Encoder` as a sub-component instead of a `Layout`.

In practical terms, this means that configuration files need to be changed

from (DEPRECATED)

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
      <file>testFile.log</file>
      ...
      <layout class="ch.qos.logback.classic.PatternLayout">
        <pattern>%msg%n</pattern>
      </layout>
    </appender>

or the shorter equivalent (DEPRECATED)

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
      <file>testFile.log</file>
      ...
      <!-- layout are assigned the type ch.qos.logback.classic.PatternLayout by default -->
      <layout>
        <pattern>%msg%n</pattern>
      </layout>
    </appender>

to (GOOD)

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
      <file>testFile.log</file>
      ...
      <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>%msg%n</pattern>
      </encoder>
    </appender>

or the shorter equivalent (GOOD)

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
      <file>testFile.log</file>
      ...
      <!-- encoders are assigned the type
           ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
      <encoder>
        <pattern>%msg%n</pattern>
      </encoder>
    </appender>

For layout type other than `PatternLayout`, for example `HTMLLayout`, your configuration files need to be changed

from (DEPRECATED)

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
      <file>testFile.log</file>
      ...
      <layout class="ch.qos.logback.classic.html.HTMLLayout">
        <pattern>%msg%n</pattern>
      </layout>
    </appender>

to (GOOD)

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
      <file>testFile.log</file>
      ...
      <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
        <layout class="ch.qos.logback.classic.html.HTMLLayout">
          <pattern>%msg%n</pattern>
        </layout>
      </encoder>
    </appender>

We hope to make up for this inconvenience with cool new features which are only possible using encoders. During a transition period, layouts passed as parameter will be automatically wrapped by an encoder so that configuration files in the old format (using a layout instead of encoder) will continue to work unmodifed.

No remote host or address is set for `SocketAppender`

A remote host or address is mandatory for SocketAppender.

You can specify the remote host in the configuration file as follows.

    <appender name="SOCKET"
      class="ch.qos.logback.classic.net.SocketAppender">
      ...
      <remoteHost>127.0.0.1</remoteHost>
      ...
    </appender>

No remote port is set for `SocketAppender`

A remote port is mandatory for SocketAppender.

You can specify the remote port in the configuration file like this:

    <appender name="SOCKET" class="ch.qos.logback.classic.net.SocketAppender">
      ...
      <port>4560</port>
      ...
    </appender>

No `Layout` is set for SMTPAppender

A `Layout` is mandatory for `SMTPAppender`. It allows SMTPAppender to format logging events before sending an email.

You can specify the `Layout` in a configuration file as follows:

    <appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
      ...
      <layout class="ch.qos.logback.classic.PatternLayout">
        <pattern>%date [%thread] %-5level %logger - %msg%n"></pattern>
      </layout>
      ...
    </appender>

SMTPAppender is known to work well with PatternLayout and HTMLLayout.

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

- The number has to be an integer
- You can add 'KB', 'MB' or 'GB' after the number.

Here are some correct values: 500KB, 15MB, 2GB.

No `TriggeringPolicy` was set for the `RollingFileAppender`.

The `RollingFileAppender` must be set up with a `TriggeringPolicy`. It permits the Appender to know when the rollover must be activated.

To find more information about `TriggeringPolicy` objects, please read the following javadocs:

- `SizeBasedTriggeringPolicy`
- `TimeBasedRollingPolicy`

Please note that the `TimeBasedRollingPolicy` is a TriggeringPolicy and and `RollingPolicy` at the same time.

No `RollingPolicy` was set for the `RollingFileAppender`.

The `RollingFileAppender` must be set up with a `RollingPolicy`. It permits the Appender to know what to do when a rollover is requested.

To find more information about `RollingPolicy` objects, please read the following javadocs:

- `FixedWindowRollingPolicy`
- `TimeBasedRollingPolicy`

Please note that the `TimeBasedRollingPolicy` is a `TriggeringPolicy` and and RollingPolicy at the same time.

The FileNamePattern property is mandatory for both `TimeBasedRollingPolicy` and `FixedWindowRollingPolicy`.

The FileNamePattern property for both `TimeBasedRollingPolicy` and `FixedWindowRollingPolicy` is mandatory.

Please refer to the documentation of TimeBasedRollingPolicy and FixedWindowRollingPolicy for examples.

The File property must be set before any rolling policy or triggering policy.

The File property, if present, must be placed before any rolling policy or triggering policy. Thus, in a configuration file, the File property, if present, must be declared declared before any rolling policy or triggering policy declarations.

Failed to rename file [x] to [y].

A log file cannot be renamed if there are handles referencing that file. For example, when the file is read by another process such as `less`, `tail`, etc. During application hot-redeployment, the old instance of the application will have open references to log files until the old instance is completely shutdown or until the `stop()` method on its `LoggerContext` is invoked.

On the Windows platform, Process Explorer can help you locate the processes which reference a given file (Find -> Find Handle or DLL). On Linux, you can use the `lsof pathToFile` command to find which process has the file given by pathToFile open.

In practice, it can be hard to ensure that there are no file handle references to log files. It can be easier to avoid file renaming altogether. As a first step, let us note that for `TimeBasedRollingPolicy`, the file option can be omitted. If omitted, no file renaming will be performed during roll over. Thus, in order to avoid file renaming errors just leave blank the file option of `RollingFileAppender`, as shown in the next configuration snippet.

    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <!-- file option left unset/blank -->
      <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>mylog.%d{yyyy-MM-dd}.log</fileNamePattern>
      </rollingPolicy>

      <encoder>
        <pattern>%relative [%thread] %level %logger - %msg%n</pattern>
      </encoder>
    </appender>

For `FixedWindowRollingPolicy`, the file option is mandatory.

The File property must be set before `FixedWindowRollingPolicy`

The File property is mandatory with `FixedWindowRollingPolicy`. Moreover, the File option must be set before the `FixedWindowRollingPolicy` element.

Refer to the logback manual on FixedWindowRollingPolicy for more information.

Prudent mode is not supported with `FixedWindowRollingPolicy`.

Given that `FixedWindowRollingPolicy` performs multiple file rename operations during roll over, and that these operations cannot be guaranteed to be safe in a multi-JVM context, prudent mode is not allowed in conjuction with a `FixedWindowRollingPolicy`.

SyslogAppender does not admit a layout.

Given that the format of a syslog request follows strict rules, you cannot freely specify the layout to be used with SyslogAppender. However, you can use SuffixPattern option instead to influence the contents of the message sent to the syslog daemon.

For more information on SyslogAppender please refer to the its documentation.

Only and only one appender can be nested the <sift> element in `SiftingAppender`.

SiftingAppender admits one and only one nested appender.