public class LoggingConfigurator extends Object
One aspect of the logging is that we setup a general uncaught exception handler to log uncaught exceptions at info level, if syslog is chosen as logging backend.
For some integration with JewelCLI| Modifier and Type | Class and Description |
|---|---|
static class |
LoggingConfigurator.Level |
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_IDENT |
static String |
SPOTIFY_HOSTNAME |
static String |
SPOTIFY_SYSLOG_HOST |
static String |
SPOTIFY_SYSLOG_PORT |
| Constructor and Description |
|---|
LoggingConfigurator() |
| Modifier and Type | Method and Description |
|---|---|
static net.kencochrane.raven.logback.SentryAppender |
addSentryAppender(String dsn)
Add a sentry appender for error log event.
|
static net.kencochrane.raven.logback.SentryAppender |
addSentryAppender(String dsn,
LoggingConfigurator.Level logLevelThreshold)
Add a sentry appender.
|
static void |
configure(File file)
Configure logging using a logback configuration file.
|
static void |
configure(File file,
String defaultIdent)
Configure logging using a logback configuration file.
|
(package private) static void |
configure(JewelCliLoggingOptions opts)
Deprecated.
Don't use, see docs.
|
static void |
configureDefaults()
Configure logging with default behaviour and log to stderr.
|
static void |
configureDefaults(String ident)
Configure logging with default behaviour and log to stderr using INFO logging level.
|
static void |
configureDefaults(String ident,
LoggingConfigurator.Level level)
Configure logging with default behaviour and log to stderr.
|
static void |
configureNoLogging()
Mute all logging.
|
static void |
configureSyslogDefaults(String ident)
Configure logging with default behavior and log to syslog using INFO logging level.
|
static void |
configureSyslogDefaults(String ident,
LoggingConfigurator.Level level)
Configure logging with default behavior and log to syslog.
|
static void |
configureSyslogDefaults(String ident,
LoggingConfigurator.Level level,
String host,
int port)
Configure logging with default behavior and log to syslog.
|
static void |
configureSyslogDefaults(String ident,
LoggingConfigurator.Level level,
String host,
int port,
String loggerName)
Configure logging with default behavior and log to syslog.
|
private static String |
getMyPid() |
private static String |
getSpotifyHostname() |
private static ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> |
getStdErrAppender(ch.qos.logback.classic.LoggerContext context)
Create a stderr appender.
|
(package private) static ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> |
getSyslogAppender(ch.qos.logback.classic.LoggerContext context,
String host,
int port)
Create a syslog appender.
|
private static String |
getSyslogHost() |
private static int |
getSyslogPort() |
private static ch.qos.logback.classic.LoggerContext |
setupLoggerContext(ch.qos.logback.classic.Logger rootLogger,
String ident) |
public static final String DEFAULT_IDENT
public static final String SPOTIFY_HOSTNAME
public static final String SPOTIFY_SYSLOG_HOST
public static final String SPOTIFY_SYSLOG_PORT
public static void configureNoLogging()
public static void configureDefaults()
DEFAULT_IDENT
logging identity. Uses INFO logging level. If the SPOTIFY_SYSLOG_HOST or SPOTIFY_SYSLOG_PORT
environment variable is defined, the syslog appender will be used, otherwise console appender
will be.public static void configureDefaults(String ident)
ident - The logging identity.public static void configureDefaults(String ident, LoggingConfigurator.Level level)
ident - The logging identity.level - logging level to use.public static void configureSyslogDefaults(String ident)
ident - Syslog ident to use.public static void configureSyslogDefaults(String ident, LoggingConfigurator.Level level)
ident - Syslog ident to use.level - logging level to use.public static void configureSyslogDefaults(String ident, LoggingConfigurator.Level level, String host, int port)
ident - Syslog ident to use.level - logging level to use.host - Hostname or IP address of syslog host.port - Port to connect to syslog on.public static void configureSyslogDefaults(String ident, LoggingConfigurator.Level level, String host, int port, String loggerName)
ident - Syslog ident to use.level - logging level to use.host - Hostname or IP address of syslog host.port - Port to connect to syslog on.loggerName - Name of the logger to which the syslog appender will be addedpublic static net.kencochrane.raven.logback.SentryAppender addSentryAppender(String dsn)
dsn - the sentry dsn to use (as produced by the sentry webinterface).public static net.kencochrane.raven.logback.SentryAppender addSentryAppender(String dsn, LoggingConfigurator.Level logLevelThreshold)
dsn - the sentry dsn to use (as produced by the sentry webinterface).logLevelThreshold - the threshold for log events to be sent to sentry.private static ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> getStdErrAppender(ch.qos.logback.classic.LoggerContext context)
context - The logger context to use.static ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> getSyslogAppender(ch.qos.logback.classic.LoggerContext context,
String host,
int port)
context - The logger context to use.host - The host running the syslog daemon.port - The port to connect to.static void configure(JewelCliLoggingOptions opts)
public static void configure(File file)
file - A logback configuration file.public static void configure(File file, String defaultIdent)
file - A logback configuration file.defaultIdent - Fallback logging identity, used if not specified in config file.private static ch.qos.logback.classic.LoggerContext setupLoggerContext(ch.qos.logback.classic.Logger rootLogger,
String ident)
private static String getMyPid()
private static String getSyslogHost()
private static int getSyslogPort()
private static String getSpotifyHostname()
Copyright © 2016. All Rights Reserved.