ECLoggingConfiguration *loggingConfiguration; ECDefaultLoggingFormatter *loggingFormatter loggingWriter = [[[ECFileLoggingWriter alloc] init] autorelease]; [loggingWriter setBaseFilename: @"sample.log"]; loggingConfiguration = [[[ECLoggingConfiguration alloc] init] autorelease];The previous code registered a particular logging configuration using the context name "sample.context". Implementations may now use this configuration/logger by referring to this context:
[loggingConfiguration setLoggingLevel: @"DEBUG ]; [loggingConfiguration setLoggingWriter: loggingWriter]; [loggingConfiguration setLoggingFormatter: [[[ECDefaultLoggingFormatter alloc] init] autorelease]]; [[ECLogging instance] addLoggingConfiguration: loggingConfiguration forContext: @"sample.context"];
ECLogger *logger = [ECLogging loggerForContext: @"sample.context"]; if( [logger isDebugEnabled] ) { [logger debug: @"This is a logging message of level DEBUG!"]; }Contexts are hierarchically organized, where the dot "." separates a super-context from its sub-contexts. The selection of a logger therefor functions as follows: a configuration for a given context is valid for all the sub-contexts except for those child contexts defining their own configuration. Say you have defined logging configurations for the following contexts:
if( [logger isTraceEnabled] ) { [logger trace: @"Trace is given hereby..."]; } if( [logger isInfoEnabled] ) { [logger info: @"This is a logging message of level INFO!"]; } [logger error: @"Logging with error code=%u and msg=%@", 112, @"Error Message" ];
and ECNSLogLoggingWriter as the
default logging writer
addLoggingConfiguration: |
adds a logging configuration for the given context.
See Also:
- addLoggingConfiguration:forContext:
- addLoggingConfiguration: (ECLoggingConfiguration *) aConfiguration forContext: (NSString *) aContext;
aConfiguration
- configuration to register
aContext
- context to register the configuration under
addLoggingConfiguration:forContext: |
adds a logging configuration for the given context.
See Also:
- addLoggingConfiguration:
- addLoggingConfiguration: (ECLoggingConfiguration *) aConfiguration forContext: (NSString *) aContext;
aConfiguration
- configuration to register
aContext
- context to register the configuration under
addRootLoggingConfiguration: |
defines the logger which is used in case a logger could not be found for a particular context
- addRootLoggingConfiguration: (ECLoggingConfiguration *) aConfiguration;
aConfiguration
- configuration of the logger
createAllSupercontextsOf: |
creates all super contexts of a given context string.
- (NSArray *) createAllSupercontextsOf: (NSString *) aContextStr;
The set of super contexts of e.g. "com.company.context" is {"com.company", "com"}.
forContext |
Return a logging instance suitable for the given context.
See Also:
- loggerForContext:
+ (ECLogger *) loggerForContext: (NSString *) aContext;
aContext
- implicitly specifies the output channel to be used
init |
initializes this object using the default logging formatter
and ECNSLogLoggingWriter as the
default logging writer
- init;
instance |
+ (ECLogging *) instance;
loggerForContext:((NSString *)) |
determines the logger for the given context
- (ECLogger *) loggerForContext: (NSString *) aContext;
loggerForContext:((NSString *), (ECLoggingConfiguration *), (ECLoggingConfiguration *), (NSString *), (NSString *), (NSString *)) |
Return a logging instance suitable for the given context.
See Also:
- forContext
+ (ECLogger *) loggerForContext: (NSString *) aContext;
aContext
- implicitly specifies the output channel to be used
(Last Updated August 27, 2006)