Pode
Pode copied to clipboard
Enable-PodeErrorLogging cannot out-file
Question
A clear and concise description of your question. #Error Log Enabled $method = New-PodeLoggingMethod -Custom -ScriptBlock { param($item) "$($item.Server) - $($item.Message)" | Out-File -FilePath 'D:\podebucket\pscode\bridge\logs\error.log' } $method | Enable-PodeErrorLogging -Raw
Hi @Badgerati
I encountered an issue, like enable-podeerrorlogging cannot output to a file, the normal way does not work, so I use custom way it does not work also.
Would you please advise how I should do, error log and redirect to a file. Requestlogging is fine, but I want errorlogging.
Thanks Eric Xin
Hi @ericxin1982
for me it just works as described in the tutorials
https://badgerati.github.io/Pode/Tutorials/Logging/Methods/File/ https://badgerati.github.io/Pode/Tutorials/Logging/Types/Errors/
New-PodeLoggingMethod -File -Name 'errors' | Enable-PodeErrorLogging
Do you have any error message or does the file just not get created?
Do you have an example code of the non-working one?
I do not have any error message, just the file not get created.
request no issue, I can see the file created. I am using the latest edtion.
Ooooh, @ericxin1982 are you expecting to see those Verbose lines in the terminal, but in a file instead? If so, then yes unfortunately those specific logs don't currently get redirected to file - they're generated by the underlying .NET library for Pode's socket listener.
It is something I've been thinking about how to redirect them to file actually, as I need to redirect logs from the .NET library up to PowerShell where the logging logic is - or, I move the inbuilt logging logic into the .NET library.
I'll try an have think about it for 2.9.0, but might be one for 2.10.0.
Hi @Badgerati
I see. I do not have to see verbose directed to the file, I just make all log can be in one place, and I do not know what can cause informational, warning, error these higher error, would you please give me a way, I just want to make sure log file can be created, if verbose cannot, that is ok.
I am using -levels * that is fine, I just want to make sure the file can be created, and something can be there. That is fine. Actually I try to create a skeleton and share this good thing to let more person know, then I have to try each single chapter content.
Thanks Eric Xin
Hi @ericxin1982,
You can write custom error logs by using Write-PodeErrorLog: https://badgerati.github.io/Pode/Tutorials/Logging/Types/Errors/#writing-errors
Hi @Badgerati
How to generate information error, debug error or warning error. I want to see the file log works as the tutorial said.
Thanks Eric Xin