コード例 #1
0
        public static Configurer WithArkDefaultTargetsAndRules(this Configurer @this, string logTableName, string connectionString, string mailFrom, string mailTo, string smtpConnectionString, bool consoleEnabled = false, bool async = true)
        {
            if (consoleEnabled)
            {
                @this
                .WithConsoleTarget(async)
                .WithConsoleRule("*", LogLevel.Trace);
            }

            if (!string.IsNullOrWhiteSpace(connectionString))
            {
                @this
                .WithDatabaseTarget(logTableName, connectionString, async)
                .WithDatabaseRule("*", LogLevel.Info);
            }

            if (!string.IsNullOrWhiteSpace(smtpConnectionString))
            {
                @this
                .WithMailTarget(mailFrom, mailTo, smtpConnectionString, async: false)
                .WithMailRule("*", LogLevel.Fatal)
                ;
            }

            if (Debugger.IsAttached)
            {
                @this
                .WithDebuggerTarget()
                .WithDebuggerRule()
                ;
            }

            return(@this);
        }
コード例 #2
0
 public static Configurer WithDefaultTargets(this Configurer @this, string logTableName, string connectionString, string mailFrom, string mailTo, bool async = true)
 {
     return(@this.WithConsoleTarget(async)
            .WithDatabaseTarget(logTableName, connectionString, async)
            .WithMailTarget(mailFrom, mailTo, async: false)
            );
 }
コード例 #3
0
 public static Configurer WithDefaultTargetsFromCloudConfiguration(this Configurer @this, string logTableName, string mailFrom, string mailTo, bool async = true)
 {
     return(@this.WithConsoleTarget(async)
            .WithFileTarget(async)
            .WithDatabaseTargetFromCloudConfiguration(logTableName, async)
            .WithMailTargetFromCloudConfiguration(mailFrom, mailTo, async: false)
            );
 }
コード例 #4
0
ファイル: NlogConfigurer.cs プロジェクト: mpvyard/Ark.Tools
 public static Configurer WithDefaultTargets(this Configurer @this, string logTableName, string connectionString, string mailFrom, string mailTo,
                                             string smtpServer, int smtpPort, string smtpUserName, string smtpPassword, bool useSsl,
                                             bool async = true)
 {
     return(@this.WithConsoleTarget(async)
            .WithFileTarget(async)
            .WithDatabaseTarget(logTableName, connectionString, async)
            .WithMailTarget(mailFrom, mailTo, smtpServer, smtpPort, smtpUserName, smtpPassword, useSsl, async: false)
            );
 }
コード例 #5
0
        public static Configurer WithDefaultTargets(this Configurer @this, string logTableName, string connectionString, string mailTo,
                                                    string smtpServer, int smtpPort, string smtpUserName, string smtpPassword, bool useSsl,
                                                    bool async = true)
        {
            var smtp = new SmtpConnectionBuilder();

            smtp.Server   = smtpServer;
            smtp.Port     = smtpPort;
            smtp.Username = smtpUserName;
            smtp.Password = smtpPassword;
            smtp.UseSsl   = useSsl;

            return(@this.WithConsoleTarget(async)
                   .WithDatabaseTarget(logTableName, connectionString, async)
                   .WithMailTarget(mailTo, smtpServer, smtpPort, smtpUserName, smtpPassword, useSsl, async: false)
                   );
        }
コード例 #6
0
        public static Configurer WithArkDefaultTargetsAndRules(this Configurer @this, string logTableName, string connectionString, string mailFrom, string mailTo, bool isProduction = true, bool async = true)
        {
            @this.WithConsoleTarget(async);

            if (!isProduction)
            {
                @this.WithConsoleRule("*", LogLevel.Trace);
            }
            else
            {
                @this.WithConsoleRule("*", LogLevel.Warn);
            }

            if (!string.IsNullOrWhiteSpace(connectionString))
            {
                @this
                .WithDatabaseTarget(logTableName, connectionString, async)
                .WithDatabaseRule("*", LogLevel.Info);
            }

            // assume system.mail

            @this
            .WithMailTarget(mailFrom, mailTo, async: false)
            .WithMailRule("*", LogLevel.Fatal)
            ;

            if (Debugger.IsAttached)
            {
                @this
                .WithDebuggerTarget()
                .WithDebuggerRule()
                ;
            }

            return(@this);
        }