如何让winston-mongodb同时登录不同的馆藏
var winston = require('winston');
require('winston-mongodb').MongoDB;
var logger = new winston.Logger({
level: 'info',
transports: [
new(winston.transports.MongoDB)({
db : 'mongodb://xxxx'
})
],
capped : true, // defaults to false
})
这个会将所有内容记录到默认集合log
,但我需要为每个模块创建一个集合,因此我知道在哪里调查特定域的某些问题
答案 0 :(得分:0)
简单直接,我们可以根据需要将日志引导到任意数量的集合:
$array = New-Object System.Collections.ArrayList
ForEach($domain in ((Get-ADForest).Domains)){
ForEach($group in (Get-ADGroup -Filter * -Properties Members -Server $domain | ? {-not $_.members})){
$temp = [PSCustomObject] @{'1 Security' = $group | ? {$_.GroupCategory -like "Security" -and $_.DistinguishedName -like "*1*"} | Select -ExpandProperty Name
'1 Distro' = $group | ? {$_.GroupCategory -like "Distribution" -and $_.DistinguishedName -like "*1*"} | Select -ExpandProperty Name
'2 Security' = $group | ? {$_.GroupCategory -like "Security" -and $_.DistinguishedName -like "*2*"} | Select -ExpandProperty Name
'2 Distro' = $group | ? {$_.GroupCategory -like "Distribution" -and $_.DistinguishedName -like "*2*"} | Select -ExpandProperty Name
'3 Security' = $group | ? {$_.GroupCategory -like "Security" -and $_.DistinguishedName -like "*3*"} | Select -ExpandProperty Name
'3 Distro' = $group | ? {$_.GroupCategory -like "Distribution" -and $_.DistinguishedName -like "*3*"} | Select -ExpandProperty Name
}
$array.Add($temp) | Out-Null
}
}
$array