# LoggingService

LoggingService is used to log messages and exceptions relating to system operation.

    public abstract class LoggingService extends Service
    {
        public final void logError( String message )
        public final void logError( String message, Throwable e )
        public final void logWarning( String message )
        public final void log( Throwable e )
        public abstract void log( Status status )
    }

Example

    try
    {
        ...
    }
    catch( Exception e )
    {
        Sapphire.service( LoggingService.class ).log( e );
    }

Two implementations are provided with Sapphire. One writes to the system error stream and another writes to the Eclipse platform log if the framework is running in the context of Eclipse.

If an alternate log strategy is desired, a custom LoggingService implementation can be supplied.

Example

    public class ExampleLoggingService extends LoggingService
    {
        @Override
        public void log( Status status )
        {
            ...
        }
    }

    <extension xmlns="http://www.eclipse.org/sapphire/xmlns/extension">
        <service>
            <id>ExampleLoggingService</id>
            <implementation>org.eclipse.sapphire.examples.ExampleLoggingService</implementation>
            <context>Sapphire</context>
            <overrides>Sapphire.LoggingService.Standard</overrides>
            <overrides>Sapphire.LoggingService.Platform</overrides>
        </service>
    </extension>

Copyright (c) 2015 Oracle
Content made available under the terms of Eclipse Public License.