Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / EventLogger.cs / 1 / EventLogger.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Install { using System; using System.Diagnostics; using System.Globalization; using System.ComponentModel; internal static class EventLogger { const int MaxEventLogLength = 32768; static MsiStyleLogWriter msiStyleLogWriter = null; static EventLogger() { if (!EventLog.SourceExists(ServiceModelInstallStrings.EventLogSource)) { EventLog.CreateEventSource(ServiceModelInstallStrings.EventLogSource, ServiceModelInstallStrings.EventLogName); } } internal static void InitializeMsiStyleLogging() { EventLogger.msiStyleLogWriter = MsiStyleLogWriter.CreateWriter(); } internal static void TerminateMsiStyleLogging() { if (EventLogger.msiStyleLogWriter != null) { DateTime now = DateTime.Now; EventLogger.msiStyleLogWriter.WriteRaw(SR.GetString(SR.MsiStyleLogTerminator, now.ToShortDateString(), now.ToString("HH:mm:ss", CultureInfo.CurrentCulture))); } EventLogger.msiStyleLogWriter = null; } internal static void LogException(Exception e) { EventLogger.LogToConsole(SR.GetString(SR.Error, e.Message)); EventLogger.WriteMsiStyleLogEntry(e.ToString()); EventLogger.WriteLogEntry(e.ToString(), EventLogEntryType.Error); } internal static void LogError(string message) { EventLogger.LogToConsole(message); EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.Error, message)); EventLogger.WriteLogEntry(message, EventLogEntryType.Error); } internal static void LogInformation(string message, bool displayToConsole) { if (displayToConsole) { EventLogger.LogToConsole(message); } EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.Information, message)); EventLogger.WriteLogEntry(message, EventLogEntryType.Information); } internal static void LogToConsole(string message) { Console.WriteLine(); Console.WriteLine(message); } internal static void LogWarning(string message, bool displayToConsole) { if (displayToConsole) { EventLogger.LogToConsole(message); } EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.Warning, message)); EventLogger.WriteLogEntry(message, EventLogEntryType.Warning); } internal static void WriteLogEntry(string message, EventLogEntryType entryType) { try { EventLog.WriteEntry(ServiceModelInstallStrings.EventLogSource, message.Trim(), entryType); } catch (ArgumentException e) { // Issues related to message length EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.ErrorWritingEventLogEntry, e.ToString())); } catch (InvalidOperationException e) { // Registry access issues EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.ErrorWritingEventLogEntry, e.ToString())); } catch (Win32Exception e) { // Other OS reported issues EventLogger.WriteMsiStyleLogEntry(SR.GetString(SR.ErrorWritingEventLogEntry, e.ToString())); } } internal static void WriteMsiStyleLogEntry(string message) { if (EventLogger.msiStyleLogWriter != null) { EventLogger.msiStyleLogWriter.WriteEntry(message); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpWrapper.cs
- ScaleTransform3D.cs
- control.ime.cs
- AuthorizationContext.cs
- DispatchProxy.cs
- Trustee.cs
- ButtonBaseAutomationPeer.cs
- ReadOnlyDataSource.cs
- DataAdapter.cs
- Rijndael.cs
- MissingManifestResourceException.cs
- DelegateInArgument.cs
- BackoffTimeoutHelper.cs
- RootDesignerSerializerAttribute.cs
- EntityTemplateUserControl.cs
- SoapExtensionImporter.cs
- ReferencedAssembly.cs
- printdlgexmarshaler.cs
- ProxySimple.cs
- Vector3DConverter.cs
- EventMetadata.cs
- DataBoundControl.cs
- HandlerBase.cs
- WSSecurityTokenSerializer.cs
- XmlMembersMapping.cs
- DesignerResources.cs
- RangeBaseAutomationPeer.cs
- RadioButton.cs
- CreateUserErrorEventArgs.cs
- CodeArrayCreateExpression.cs
- QueueSurrogate.cs
- GraphicsContainer.cs
- DefaultEventAttribute.cs
- DocumentManager.cs
- BamlBinaryWriter.cs
- DiscardableAttribute.cs
- TextBoxView.cs
- DateTimeValueSerializerContext.cs
- DispatcherOperation.cs
- FontSource.cs
- ToolBar.cs
- HtmlForm.cs
- CqlGenerator.cs
- ObjectConverter.cs
- SharedMemory.cs
- Mapping.cs
- TableCell.cs
- CounterCreationDataConverter.cs
- ReliableDuplexSessionChannel.cs
- Material.cs
- SortKey.cs
- X509CertificateValidator.cs
- RecognizerStateChangedEventArgs.cs
- WeakHashtable.cs
- GradientPanel.cs
- OLEDB_Util.cs
- RC2CryptoServiceProvider.cs
- QualifiedCellIdBoolean.cs
- DrawingImage.cs
- XmlDesigner.cs
- CompiledQueryCacheKey.cs
- FixedHyperLink.cs
- FieldNameLookup.cs
- CookieProtection.cs
- FixedPosition.cs
- PageCache.cs
- ConfigXmlAttribute.cs
- PropVariant.cs
- CodeDomExtensionMethods.cs
- CodeStatementCollection.cs
- WCFBuildProvider.cs
- ImageField.cs
- InputReportEventArgs.cs
- ModelService.cs
- Configuration.cs
- PlatformCulture.cs
- SByteConverter.cs
- dataobject.cs
- MetadataElement.cs
- SamlAssertion.cs
- ChannelServices.cs
- SEHException.cs
- GenerateHelper.cs
- ErrorWebPart.cs
- WCFServiceClientProxyGenerator.cs
- ServiceInstanceProvider.cs
- CodeNamespace.cs
- DecodeHelper.cs
- FileVersionInfo.cs
- ApplicationActivator.cs
- StylusLogic.cs
- Listbox.cs
- PassportAuthenticationModule.cs
- ServicePointManagerElement.cs
- LateBoundBitmapDecoder.cs
- BamlRecordWriter.cs
- PerfCounters.cs
- FileDialog_Vista.cs
- URI.cs
- ZipIORawDataFileBlock.cs