You can log items to a file using Pode's inbuilt file logging logic. The inbuilt logic allows you to define a maximum number of days to keep files, as well as a maximum file size. The logic will convert any item to a string, and then write it to file.
By default, Pode will create all log files in a
./logs directory at the root of your server. Each log file will be stored by day, eg:
<name>_2019-08-02_001.log. The last
001 number specifies the log number for that day - if files are be limited by size.
The following example will setup the file logging method for logging Requests:
New-PodeLoggingMethod -File -Name 'requests' | Enable-PodeRequestLogging
The following example will configure file logging to only keep a maximum number of days of logs. Ie, if you set
-MaxDays to 4, then Pode will only store the last 4 days worth of logs.
New-PodeLoggingMethod -File -Name 'requests' -MaxDays 4 | Enable-PodeRequestLogging
The following example will configure file logging to keep logging to a file until it reaches a maximum size. Once the size is reach, Pode will start logging to a new file; in this case, you'll see the last 3 digits increment:
001 > 002.
In this example, the maximum size it limited to 10MB:
New-PodeLoggingMethod -File -Name 'requests' -MaxSize 10MB | Enable-PodeRequestLogging
By default Pode puts all logs in the
./logs directory. You can use a custom path by using
New-PodeLoggingMethod -File -Name 'requests' -Path 'E:/logs' | Enable-PodeRequestLogging