@manhng

Welcome to my blog!

Debug (NET)

January 16, 2022 12:23

Debug (edit)

protected void Application_Error()
{
var ex = Server.GetLastError();
Logger.Log.Error(ex);
}

log4net.Config.XmlConfigurator.Configure();

public class Logger
{
private static readonly ILog log = LogManager.GetLogger(typeof(Logger));

public static ILog Log
{
get { return Logger.log; }
}
}

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>

<!-- log4net -->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

...

</configSections>

...

<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Logs\Debug.txt" />
</listeners>
</trace>
</system.diagnostics>

<!-- log4net -->
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\Logs\Debug.log" />
<appendToFile value="true" />
<encoding value="UTF-8" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date{dd-MM-yy HH:mm:ss} %-5level %message%newline" />
</layout>
</appender>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{dd-MM-yy HH:mm:ss} %-5level %message%newline" />
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5level %message%newline" />
</layout>
</appender>
<root>
<level value="All" />
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="TraceAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
</configuration>

Debug & Log

June 21, 2019 15:23

Debug & Log (edit)

SQL Prompt

OZCODE

CODEMAID

DebugView

https://tedgustaf.com/blog/2011/use-debugview-to-view-debug-output-from-asp-net-web-application/

Published: April 23, 2019

https://docs.microsoft.com/en-us/sysinternals/downloads/debugview

DebugView screenshot

Debug JSON

October 6, 2017 16:51

Save JSON when HTTP POST (edit)

Debug (NET) - @manhng

var uploadsProjectsFolder = Path.Combine(_hostingEnvironment.WebRootPath, @"Uploads\Projects\");

if (!Directory.Exists(uploadsProjectsFolder)) Directory.CreateDirectory(uploadsProjectsFolder);

System.IO.File.WriteAllText($"{Path.Combine(uploadsProjectsFolder, projectId.ToSafeString())}.txt", Newtonsoft.Json.JsonConvert.SerializeObject(model));

Categories

Recent posts