-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMerge-Logback.ps1
More file actions
37 lines (29 loc) · 1.21 KB
/
Merge-Logback.ps1
File metadata and controls
37 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
param (
[ValidateScript({Test-Path -PathType Leaf -Path $_})]
[Parameter(Mandatory=$true, HelpMessage='The location of the logback.xml file')]
$logbackFile,
[ValidateSet('OFF','ERROR','WARN','INFO','DEBUG','TRACE','ALL')]
$logLevel,
$logFolder,
$logPattern,
$logHistory
)
Add-Type -Assembly System.Xml.Linq
$config = [Xml.Linq.XDocument]::Load($logbackFile)
if ($logLevel) {
$level = $config.Element('configuration').Elements('property') | ? {$_.Attribute('name').Value -eq 'log.level'}
$level.Attribute('value').Value = $logLevel
}
if ($logFolder) {
$folder = $config.Element('configuration').Elements('property') | ? {$_.Attribute('name').Value -eq 'log.folder'}
$folder.Attribute('value').Value = $logFolder -replace '\\','/'
}
if ($logPattern) {
$pattern = $config.Element('configuration').Elements('property') | ? {$_.Attribute('name').Value -eq 'log.pattern'}
$pattern.Attribute('value').Value = $logPattern
}
if ($logHistory) {
$history = $config.Element('configuration').Elements('property') | ? {$_.Attribute('name').Value -eq 'log.history'}
$history.Attribute('value').Value = $logHistory
}
$config.Save($logbackFile)