0
Fixed

Improve architecture of Logging Engine

Matthew Clark 12 years ago updated by anonymous 8 years ago 5

Please move the extended logging engine into the logging engine and logging engine base.

Please create a generic validation Action that is passed down to the log writer factories, that calls back into the engine. Add a validation routine that confirms the CSV writer doesn't conflict with others.

Additionally, the Identity Broker service (haven't tested console) is halting operation on attempt to browse to the Connector and Adapter page (the Home page is fine, haven't tested others). The following error is being thrown:

Error occurred in module: Logging

Unable to log, exception as follows:

System.IO.IOException: The process cannot access the file 'c:\test20111130.csv' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding)
at Unify.Framework.Logging.CsvLogWriter.WriteLogEntryBase(ILogEntry logEntry, String filePath)
at Unify.Framework.Logging.FileLogWriterBase.WriteLogEntryBase(ILogEntry logEntry)
at Unify.Framework.Logging.LogWriterBase.WriteLogEntry(ILogEntry logEntry)

Logging configuration attached.

Thanks.


Unify.Framework.Logging.LoggingEnginePlugInKey.extensibility.config.xml

After doing some other work and restarting the service a few minutes later, this error has disappeared. Will note on this issue if I encounter this again, or close it if not.

This occurred again when performing an adapter call against the service. The service now continues to do this on startup.

Note that this can be observed on Test 1. Some light use of a Visual Studio-hosted Identity Broker does not seem to encounter this problem.

I am able to replicate this locally by configuring a CSV log writer, and then restarting the service. Prior to the restart, the log appears to operate correctly, but on startup, the service fails. The following messages can appear as the event source in the Event Log:

Request to retrieve configuration using additional probe names method.
Request to retrieve parttion context
Request to retrieve all adapters started

After initial investigation, the cause of this error could be traced back to the use of the Asynchronous Log Writer decorator; Specifically on starting the IdentityBroker engine the log writer would set up a separate thread to write accepted log entries to.

Of the registered factories, there were two logging engines being generated

{ExtendedLoggingEngine and the LoggingEngine}

, which would create two separate instances of the Log writers. This would then subsequently have two separate threads writing the same LogEntry at the same time, to the same .CSV file. As this would happen at the same time, the second log writer would fail due to the first async. log writer still writing.

All log writers fail on unhandled exception, specifically with regards to this issue the Asynchronous Log Writer now fails as well.

Each log writer can now maintain its own validation context, within the overall context of a single logging engine instance. Specifically, only one CSV log writer can be 'active' with a specific key-pair of directory/prefix.

This is enforced by the logging engine through two methods ::LogWriterIncluded and ::LogWriterRemoved on the respective writer factories.

A log writer, with regards to a single logging engine, is seen as being 'active' if it has been created and is enabled; meaning that multiple CSV log writers can be configured with conflicting configurations as long as they are not enabled.

The IdentityBroker service will no longer crash on a failed log writer write event, and instead its internal Csv Log Reader Writer is notified.