AWS Elastic Beanstalk实例使用ASP.NET进行日志记录

时间:2016-11-20 23:50:52

标签: windows amazon-web-services elastic-beanstalk

我在AWS Elastic Beanstalk上运行了一个ASP.NET应用程序。网站运行正常,但我无法配置AWS尾日志来获取log4net日志文件。

我正在使用log4net将日志输出到文件,如下所示。

from collections import Counter
result = Counter(name for _, name, _ in lst)

我在我的项目中创建了<appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> <file value="C:\testlog.log" /> <appendToFile value="true" /> <maximumFileSize value="5MB" /> <maxSizeRollBackups value="2" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %level %thread %logger - %message%newline" /> </layout> </appender> (如here所述)并将其复制到输出中(我已经验证AWS在AWS控制台事件日志中创建了该文件)。

.ebextensions\testlog.config

当我尝试获取日志(日志 - &gt;请求日志 - &gt;前100行 - &gt;下载)时,我看到此错误:

files:
  "c:/Program Files/Amazon/ElasticBeanstalk/config/taillogs.d/testlog.conf" :
    content: |
      C:\testlog.log

我已尝试登录到不同的文件路径(Faulting application path: c:\Program Files\Amazon\ElasticBeanstalk\Tools\TailLogs.exe Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll Report Id: df345c3f-af75-11e6-8155-06f0078a1fb7 Faulting package full name: Faulting package-relative application ID: 2016-11-20T23:05:48.000Z Error 0:(0) .NET Runtime - Application: TailLogs.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentException at System.IO.Path.LegacyNormalizePath(System.String, Boolean, Int32, Boolean) at System.IO.Path.NormalizePath(System.String, Boolean, Int32, Boolean) at System.IO.Path.GetFullPathInternal(System.String) at System.IO.DirectoryInfo.Init(System.String, Boolean) at System.IO.DirectoryInfo..ctor(System.String) at AWSBeanstalkCfnUtility.LogInfo.GetLogFiles(System.String) at AWSBeanstalkCfnUtility.FileUtil.scanLogDirectories(System.IO.TextWriter, System.Collections.Generic.IEnumerable`1<AWSBeanstalkCfnUtility.LogInfo>) at AWSBeanstalkCfnTailLogsApp.Program.Main(System.String[]) C:\inetpub\logs\),但我一直收到同样的错误。

关于我做错的任何想法?

1 个答案:

答案 0 :(得分:0)

我找到了问题的原因,我需要为日志进入的文件夹设置写权限。

container_commands:
  01-changeperm:
    command: icacls.exe c:\\inetpub\\logs /grant "IIS AppPool\DefaultAppPool":(OI)(CI)M > c:\\cfn\\perms.log 2>&1
    waitAfterCompletion: 0

files:
  "c:/Program Files/Amazon/ElasticBeanstalk/config/taillogs.d/applog.conf":
    content: |
      C:\inetpub\logs\app.log