Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format, include, exclude, customize the headers and generate log #654

Open
ericfran opened this issue Jan 7, 2025 · 4 comments
Open

Format, include, exclude, customize the headers and generate log #654

ericfran opened this issue Jan 7, 2025 · 4 comments

Comments

@ericfran
Copy link

ericfran commented Jan 7, 2025

Hi,
maybe I didn't search well for the info, but is is possible to:

  • set a specific format for the log genarted line (destiantion to logfile, ...) as on the screen only the message is displayed when as with this :
    Set-PSFLoggingProvider -Name console -Enabled $true -Style '%Message%'
    Write-PSFMessage -Message 'Some text'

it displays : Some text

So is it possible to have the same when the provider is to a logfile ?
Can we set for example date, and messages or message only ?

regards,

@FriedrichWeinmann
Copy link
Member

Heya Eric,
you sure can*

Basically, you can define the properties on the message object you want (and the order you want them in).
What you can't do, is change the format. So if you configure a logfile as CSV, you get a CSV file. Maybe one with only single column - message - but it will be a valid CSV.

Anyway, the parameter you are looking for is -Headers

@ericfran
Copy link
Author

Hi,
Yes I found it by looking to members ✌️
And I could set the required column.
The only issue is that when I put the %message% it is between double-quotes 😕, can this be configured ? Be able to set or set none around message or other headers should be great, possible ?
Regards

@FriedrichWeinmann
Copy link
Member

The current implementation does not support removing the quotes - that's part of how PowerShell converts to CSV and part of that limit I mentioned.
That said, it would be a doable update.
There is a reason the logfile provider does not at this time support a free log format style: I did not want to encourage people to use a non-structured format for their logging, rather than one that is easily readable not just for humans, but also for scripts (to facilitate automated processing of logs).
That said, it's not really something I am adamant about - the audience has shifted and there is value in being able to log into a server and be able to scan the logs in a plain notepad without having to first in bring tools or use PowerShell.

Consider it queued for the next release. Probably as a new format for the logfile provider.

@ericfran
Copy link
Author

ericfran commented Jan 11, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants