Winston MongoDB:如何将日志传递给许多集合,而不是所有集合都集中在一起

时间:2015-12-08 12:16:27

标签: javascript mongodb logging winston

如何让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,但我需要为每个模块创建一个集合,因此我知道在哪里调查特定域的某些问题

1 个答案:

答案 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