为什么我的日志文件无法在azure blob存储上创建 [英] Why my logs file not creating on azure blob storage
本文介绍了为什么我的日志文件无法在azure blob存储上创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Azure Blob存储上保存我的错误日志文件。我可以通过NLog.config将这些文件存储在FTP文件夹中。
我的代码出错了。
甚至在本地机器上成功创建日志文件。
谢谢提前
我尝试过:
我的Nlog.config文件
I want to save my Error logs file on Azure Blob Storage. I am able to store these file on FTP Folder by NLog.config.
What I am doing wrong with my code.
Even Log file creating successfully on Local Machine.
Thanks in Advance
What I have tried:
My Nlog.config file
<?xml version="1.0"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwException="true" autoReload="true">
<extensions>
<add assembly="NLogExtensions" />
<add assembly="NLog.AzureBlobStorage" />
</extensions>
<targets>
<target xsi:type="ColoredConsole" name="colored_console" />
<target name="console" xsi:type="Console" layout="${longdate}|${message}" />
<target name="file" xsi:type="File" fileName="${basedir}/logs/Debug_${shortdate}.txt" layout="${longdate}|${message}" />
<target xsi:type="AzureAppendBlob" name="Azure" layout="${longdate} ${level:uppercase=true} - ${message}" connectionString="myConnectionString" container="mycontainer" blobName="${date:format=yyyy-MM-dd}.log" />
</targets>
<rules>
<logger name="*" minlevel="Error" writeTo="console,file" />
<logger name="*" minlevel="Trace" writeTo="colored_console" />
<logger name="*" minlevel="Error" writeTo="Azure" />
</rules>
</nlog>
c #代码创建日志文件
c# Code to Create Log file
using System;
using NLog;
using NLog.Fluent;
public partial class ErrorPage : System.Web.UI.Page
{
private static Logger Mysameplelogger = LogManager.GetCurrentClassLogger();
protected void Page_Load(object sender, EventArgs e)
{
LogSample();
}
static void LogSample()
{
Mysameplelogger.Trace("Trace: This is a sample Trace Log");
Mysameplelogger.Debug("Debug: This is a sample Debug Log");
Mysameplelogger.Info("Info: This is a sample Info Log");
Mysameplelogger.Warn("Warn: This is a sample Warn Log");
Mysameplelogger.Error("Error: This is a sample Error Log");
Mysameplelogger.Fatal("Fatal: This is a sample Fatal Error Log");
Mysameplelogger.Info().Message("This is a test Info message '{0}'.", DateTime.Now.Ticks).Property("Test", "InfoWrite").Write();
}
}
推荐答案
{longdate} |
{longdate}|
{message} / >
< target name = file xsi:type = < span class =code-keyword>文件 fileName =
{message}" /> <target name="file" xsi:type="File" fileName="
{basedir} / logs / Debug _
{basedir}/logs/Debug_
这篇关于为什么我的日志文件无法在azure blob存储上创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文