You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well, generally we do not recommend using those (as they are hard to process automatically, compared to structured data logs), but sometimes you just need something for a quick peek in notepad and a plain text logfile is just easy to read for the human eye.
You can write messages using the `Write-PSFMessage` cmdlet, which functionally replaces Write-Verbose, Write-Host, Write-Warning, Write-Debug or Write-Log:
Copy file name to clipboardExpand all lines: documentation/documents/psframework/logging/providers/logfile.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ It also offers logrotate capabilities, to clean up after itself.
30
30
|---|---|---|
31
31
|CsvDelimiter|,|The delimiter to use when writing to csv.|
32
32
|FilePath||The path to where the logfile is written. Supports some placeholders such as %Date% to allow for timestamp in the name.|
33
-
|FileType|CSV|In what format to write the logfile. Supported styles: CSV, XML, Html, Json or CMTrace. Html, XML and Json will be written as fragments.|
33
+
|FileType|CSV|In what format to write the logfile. Supported styles: CSV, XML, Html, Json, TXT or CMTrace. Html, XML and Json will be written as fragments.|
34
34
|Headers|'ComputerName', 'File', 'FunctionName', 'Level', 'Line', 'Message', 'ModuleName', 'Runspace', 'Tags', 'TargetObject', 'Timestamp', 'Type', 'Username'|The properties to export, in the order to select them. For writing the data field or renaming properties, see below under "Notes".|
35
35
|IncludeHeader|True|Whether a written csv file will include headers|
36
36
|Logname||A special string you can use as a placeholder in the logfile path (by using '%logname%' as placeholder)|
@@ -45,6 +45,11 @@ It also offers logrotate capabilities, to clean up after itself.
45
45
|JsonCompress|$false|Will compress the json entries, condensing each entry into a single line.|
46
46
|JsonString|$false|Will convert all enumerated properties to string values when converting to json. This causes the level property to be 'Debug','Host', ... rather than 8,2,...|
47
47
|JsonNoComma|$false|Prevent adding commas between two json entries.|
48
+
|JsonNoEmptyFirstLine|$false|Prevent the empty first line when commas have not been disabled.|
49
+
|CMTraceOverrideComponent|$false|When Enabled, messages that include a "Data" hashtable with a "Component" entry will use that Entry for the log message Component element, rather than the auto-calculated one.|
50
+
|TXTPattern|'%Timestamp% [%Level%] %Message%'|The pattern of any given line in the TXT-based logfile. Use %PROPERTYNAME% as placeholder, e.g. "%Message%". Same properties as with the headers configuration - you need to specify both settings, if your pattern includes non-default properties such as "Data".|
51
+
|MoveOnFinal|''|Path to a target folder to move logfiles to when shutting down the logging provider instance. This happens automatically when PSFramework ends or the provider instance is disabled again.|
52
+
|CopyOnFinal|''|Path to a target folder to copy logfiles to when shutting down the logging provider instance. This happens automatically when PSFramework ends or the provider instance is disabled again.|
48
53
49
54
## Notes
50
55
@@ -57,6 +62,7 @@ The default format is CSV, but there is more ...
57
62
|---|---|
58
63
|CSV|The default format. A common CSV and the only type that respects the CsvDelimiter setting. Easy to open in Excel, making it a popular format for admins. However, as it is a flat table, this format cannot support the Data field.|
59
64
|Json|Writes entries as Json string. However, as each individual write cannot guarantee it being the last to write an entry to the file, all entries are written as _fragments_ . To turn the resulting file content into valid json, wrap it into square brackets.|
65
+
|TXT|Writes a plaintext logfile. Generally not recommended, as logs in structured data formats are easier to automatically process, parse and monitor. Use the `TXTPattern` setting to define just how the log looks, all properties selected must also be included in the `Headers` setting.|
60
66
|XML|Writes entries as XML string. However, as each individual write cannot guarantee it being the last to write an entry to the file, all entries are written as _fragments_ . To turn the resulting file content into valid XML, wrap it into a `<Messages>` XML element.|
61
67
|Html|Writes entries as Html string. However, as each individual write cannot guarantee it being the last to write an entry to the file, all entries are written as _fragments_ . To turn the resulting file content into valid html, wrap it into a `<table>` html element.|
62
68
|CMTrace|Writes log entries in a format that can easily be consumed by the CMTrace log reading utility part of SCCM. This type ignores the selected headers to write and cannot support the Data field.|
Copy file name to clipboardExpand all lines: documentation/quickstart/psframework.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,11 @@ In many cases, we build helping infrastructure for our modules in as minimal a w
5
5
The PSFramework fills that gap, whether it is powerful and flexible logging, configuration management, tab completion or runspace management.
6
6
Its functionalities are split into many separate groups, these are quick start guides that are supposed to give you an easy entry into their respective group:
7
7
8
-
- Configuration: [Getting Started with Configuration](psframework/configuration.html)
9
-
- Logging: [Getting Started with Logging](psframework/logging.html)
10
-
- Parameter Classes: [Getting Started with Parameter Classes](psframework/parameter-classes.html)
11
-
- Tab Completion: [Getting Started with Tab Completion](psframework/tabcompletion.html)
8
+
- Configuration: [Getting Started with Configuration](psframework/configuration.html)
9
+
- Logging: [Getting Started with Logging](psframework/logging.html)
10
+
- Parameter Classes: [Getting Started with Parameter Classes](psframework/parameter-classes.html)
11
+
- Tab Completion: [Getting Started with Tab Completion](psframework/tabcompletion.html)
12
+
13
+
> Conference Recording
14
+
15
+
At PSConfEU 2024, Fred gave a talk on [Quick Wins with the PSFramework](https://www.youtube.com/watch?v=xD3Hh-jNOg4), which should also serve well in getting ... well quick wins / gains and accelerate adoption.
0 commit comments