本文整理汇总了C#中ILogFormatter类的典型用法代码示例。如果您正苦于以下问题:C# ILogFormatter类的具体用法?C# ILogFormatter怎么用?C# ILogFormatter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ILogFormatter类属于命名空间,在下文中一共展示了ILogFormatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetLogFormatter
public static void SetLogFormatter(LogEntry logEntry, ILogFormatter logFormatter)
{
if (logEntry != null)
{
_logFormatter = logFormatter;
}
}
示例2: RollingFlatFileTraceListener
/// <summary>
/// Initializes a new instance of the <see cref="RollingFlatFileTraceListener"/> class.
/// </summary>
/// <param name="fileName">The filename where the entries will be logged.</param>
/// <param name="header">The header to add before logging an entry.</param>
/// <param name="footer">The footer to add after logging an entry.</param>
/// <param name="formatter">The formatter.</param>
/// <param name="rollSizeKB">The maxium file size (KB) before rolling.</param>
/// <param name="timeStampPattern">The date format that will be appended to the new roll file.</param>
/// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
/// <param name="rollInterval">The time interval that makes the file rolles.</param>
/// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
public RollingFlatFileTraceListener(string fileName,
string header = DefaultSeparator,
string footer = DefaultSeparator,
ILogFormatter formatter = null,
int rollSizeKB = 0,
string timeStampPattern = "yyyy-MM-dd",
RollFileExistsBehavior rollFileExistsBehavior = RollFileExistsBehavior.Overwrite,
RollInterval rollInterval = RollInterval.None,
int maxArchivedFiles = 0)
: base(fileName, header, footer, formatter)
{
Guard.ArgumentNotNullOrEmpty(fileName, "fileName");
this.rollSizeInBytes = rollSizeKB * 1024;
this.timeStampPattern = timeStampPattern;
this.rollFileExistsBehavior = rollFileExistsBehavior;
this.rollInterval = rollInterval;
this.maxArchivedFiles = maxArchivedFiles;
this.rollingHelper = new StreamWriterRollingHelper(this);
if (rollInterval == RollInterval.Midnight)
{
var now = this.rollingHelper.DateTimeProvider.CurrentDateTime;
var midnight = now.AddDays(1).Date;
this.timer = new Timer((o) => this.rollingHelper.RollIfNecessary(), null, midnight.Subtract(now), TimeSpan.FromDays(1));
}
}
示例3: EmailMessage
/// <summary>
/// Initializes a <see cref="EmailMessage"/> with the raw data to create and email, a message, and the formatter
/// </summary>
/// <param name="toAddress">A semicolon delimited string the represents to whom the email should be sent.</param>
/// <param name="fromAddress">Represents from whom the email is sent.</param>
/// <param name="subjectLineStarter">Starting text for the subject line.</param>
/// <param name="subjectLineEnder">Ending text for the subject line.</param>
/// <param name="smtpServer">The name of the SMTP server.</param>
/// <param name="smtpPort">The port on the SMTP server to use for sending the email.</param>
/// <param name="message">Represents the message to send via email.</param>
/// <param name="formatter">The Formatter <see cref="ILogFormatter"/> which determines how the
/// email message should be formatted</param>
public EmailMessage(string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, string message, ILogFormatter formatter)
{
this.configurationData = new EmailTraceListenerData(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, smtpPort, string.Empty);
this.logEntry = new LogEntry();
logEntry.Message = message;
this.formatter = formatter;
}
示例4: WaveDrawer
public WaveDrawer(string logPath, Size chartSize, Size chartGridSize, ILogFormatter logFormatter)
{
this.logPath = logPath;
this.chartSize = chartSize;
this.logFormatter = logFormatter;
this.chartGridSize = chartGridSize;
}
示例5: EmailLogProvider
public EmailLogProvider(
DeliveryMethod deliveryMethod = null,
ILogFormatter logFormatter = null)
: base(logFormatter ?? DefaultLogFormatter)
{
_deliveryMethod = deliveryMethod ?? DefaultDeliveryMethod;
}
示例6: MsmqTraceListener
/// <summary>
/// Initializes a new instance of <see cref="MsmqTraceListener"/>.
/// </summary>
/// <param name="name">The name of the new instance.</param>
/// <param name="queuePath">The path to the queue to deliver to.</param>
/// <param name="formatter">The formatter to use.</param>
/// <param name="messagePriority">The priority for the messages to send.</param>
/// <param name="recoverable">The recoverable flag for the messages to send.</param>
/// <param name="timeToReachQueue">The timeToReachQueue for the messages to send.</param>
/// <param name="timeToBeReceived">The timeToBeReceived for the messages to send.</param>
/// <param name="useAuthentication">The useAuthentication flag for the messages to send.</param>
/// <param name="useDeadLetterQueue">The useDeadLetterQueue flag for the messages to send.</param>
/// <param name="useEncryption">The useEncryption flag for the messages to send.</param>
/// <param name="transactionType">The <see cref="MessageQueueTransactionType"/> for the message to send.</param>
/// <param name="msmqInterfaceFactory">The factory to create the msmq interfaces.</param>
public MsmqTraceListener(string name,
string queuePath,
ILogFormatter formatter,
MessagePriority messagePriority,
bool recoverable,
TimeSpan timeToReachQueue,
TimeSpan timeToBeReceived,
bool useAuthentication,
bool useDeadLetterQueue,
bool useEncryption,
MessageQueueTransactionType transactionType,
IMsmqSendInterfaceFactory msmqInterfaceFactory)
: base(formatter)
{
this.queuePath = queuePath;
this.messagePriority = messagePriority;
this.recoverable = recoverable;
this.timeToReachQueue = timeToReachQueue;
this.timeToBeReceived = timeToBeReceived;
this.useAuthentication = useAuthentication;
this.useDeadLetterQueue = useDeadLetterQueue;
this.useEncryption = useEncryption;
this.transactionType = transactionType;
this.msmqInterfaceFactory = msmqInterfaceFactory;
}
示例7: FormattedDatabaseTraceListener
/// <summary>
/// Initializes a new instance of <see cref="FormattedDatabaseTraceListener"/>.
/// </summary>
/// <param name="database">The database for writing the log.</param>
/// <param name="writeLogStoredProcName">The stored procedure name for writing the log.</param>
/// <param name="addCategoryStoredProcName">The stored procedure name for adding a category for this log.</param>
/// <param name="formatter">The formatter.</param>
public FormattedDatabaseTraceListener(Data.Database database, string writeLogStoredProcName, string addCategoryStoredProcName, ILogFormatter formatter
)
: base(formatter)
{
this.writeLogStoredProcName = writeLogStoredProcName;
this.addCategoryStoredProcName = addCategoryStoredProcName;
this.database = database;
}
示例8: DefaultOutputHandler
public DefaultOutputHandler(ILogFilters filters, ILogFormatter formatter)
{
if (filters == null)
throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation.");
this.Filters = filters;
this.Formatter = formatter;
}
示例9: AddLogWriter
public static void AddLogWriter(ILogWriter logWriter, ILogFormatter logFormatter)
{
logWriters.Add(new LogWriterInfo()
{
logWriter = logWriter,
logFormatter = logFormatter
});
}
示例10: TestCommonLoggingEntlibTraceListener
public TestCommonLoggingEntlibTraceListener(CommonLoggingEntlibTraceListenerData data, ILogFormatter logFormatter)
: base(data, logFormatter)
{
if (Instance != null)
{
throw new NotSupportedException(this.GetType().FullName + " supports only one instance");
}
Instance = this;
}
示例11: CsvFileOutputHandler
public CsvFileOutputHandler(ILogFilters filters, ILogFormatter formatter, String filePath)
{
if (filters == null)
throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation.");
this.Filters = filters;
this.Formatter = formatter;
this.FilePath = filePath;
}
示例12: CachedEmailTraceListener
public CachedEmailTraceListener(string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, ILogFormatter formatter, EmailAuthenticationMode authenticationMode, string userName, string password, bool useSSL, double emailCacheDuration)
: base(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, smtpPort, formatter, authenticationMode, userName, password, useSSL)
{
this.emailCacheDuration = emailCacheDuration;
if (emailCacheDuration > 0)
{
// Email cache duration is in hours
this.cacheItemPolicyFactory = new AbsoluteCacheItemPolicyFactory(Convert.ToInt32(emailCacheDuration * 3600));
}
}
示例13: MsmqTraceListener
/// <summary>
/// Initializes a new instance of <see cref="MsmqTraceListener"/>.
/// </summary>
/// <param name="name">The name of the new instance.</param>
/// <param name="queuePath">The path to the queue to deliver to.</param>
/// <param name="formater">The formatter to use.</param>
/// <param name="messagePriority">The priority for the messages to send.</param>
/// <param name="recoverable">The recoverable flag for the messages to send.</param>
/// <param name="timeToReachQueue">The timeToReachQueue for the messages to send.</param>
/// <param name="timeToBeReceived">The timeToBeReceived for the messages to send.</param>
/// <param name="useAuthentication">The useAuthentication flag for the messages to send.</param>
/// <param name="useDeadLetterQueue">The useDeadLetterQueue flag for the messages to send.</param>
/// <param name="useEncryption">The useEncryption flag for the messages to send.</param>
/// <param name="transactionType">The <see cref="MessageQueueTransactionType"/> for the message to send.</param>
public MsmqTraceListener(string name, string queuePath, ILogFormatter formater,
MessagePriority messagePriority, bool recoverable,
TimeSpan timeToReachQueue, TimeSpan timeToBeReceived,
bool useAuthentication, bool useDeadLetterQueue, bool useEncryption,
MessageQueueTransactionType transactionType)
: this(name, queuePath, formater, messagePriority, recoverable,
timeToReachQueue, timeToBeReceived,
useAuthentication, useDeadLetterQueue, useEncryption,
transactionType, new MsmqSendInterfaceFactory())
{
}
示例14: TextWriterOutputHandler
public TextWriterOutputHandler(TextWriter writer, ILogFilters filters, ILogFormatter formatter)
{
if (writer == null)
throw new ArgumentNullException("writer", "A valid stream writer is required for proper operation.");
if (filters == null)
throw new ArgumentNullException("filters", "A valid set of log filters is required for proper operation.");
this.Filters = filters;
this.Formatter = formatter;
this.Writer = writer;
}
示例15: MonitoringDatabaseTraceListener
/// <summary>
/// Initializes a new instance of <see cref="MonitoringDatabaseTraceListener"/>.
/// </summary>
/// <param name="database">The database for writing the log.</param>
/// <param name="formatter">The formatter.</param>
/// <param name="applicationName">Name of the application.</param>
/// <param name="connectionStringName">Name of the connection string.</param>
public MonitoringDatabaseTraceListener(Database database, ILogFormatter formatter, string applicationName,
string connectionStringName)
: base(formatter)
{
_database = database;
if (string.IsNullOrEmpty(applicationName))
{
throw new ArgumentNullException("applicationName");
}
_applicationName = applicationName;
_connectionStringName = connectionStringName;
}