使用Powershell添加IIS 8.5自定义日志记录字段 [英] Add IIS 8.5 Custom Logging Fields with Powershell
问题描述
带有IIS 8.5的Windows Server 2012 R2允许使用增强日志记录的自定义日志字段
Windows Server 2012 R2 with IIS 8.5 allows for custom log fields with Enhanced Logging
http://www.iis.net/learn/get-started/whats-new-in- iis-85 / enhanced-logging-for-iis85
我想用Powershell添加字段
I want to add the fields with Powershell
以下作品:
Set-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection -value
@{logFieldName='foo';sourceType='RequestHeader';sourceName='c-ip'}
但我无法向logfile.customFields.collection添加第二个条目它请求-Force并覆盖现有条目
But I cannot add a second entry to logfile.customFields.collection It requests -Force and overwrites the existing entry
我通过GUI添加了2说明问题
I added 2 via the GUI to illustrate the issue
Get-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection
logFieldName : foo
sourceName : c-ip
sourceType : RequestHeader
Attributes : {logFieldName, sourceName, sourceType}
ChildElements : {}
ElementTagName : add
Methods :
Schema : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema
logFieldName : foo2
sourceName : c-servername
sourceType : RequestHeader
Attributes : {logFieldName, sourceName, sourceType}
ChildElements : {}
ElementTagName : add
Methods :
Schema : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema
logFieldName,sourceName和sourceType是具有相同名称的NoteProperty成员
logFieldName, sourceName, and sourceType are NoteProperty Members with the same name
如何在Powershell中执行此操作?
How do I do this in Powershell?
推荐答案
IIS论坛已回答
New-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection -value
@{logFieldName='foo';sourceType='RequestHeader';sourceName='c-ip'}
New-ItemProperty IIS:\Sites\siteName -name logfile.customFields.collection -value
@{logFieldName='foo2';sourceType='RequestHeader';sourceName='c-ip'}
我确认这确实有效
这篇关于使用Powershell添加IIS 8.5自定义日志记录字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!