Log a Single Message
If you would like to write messages to the Plex log to record events that happen, you can use this API command to write a single message to the log. The message will include the log level, message and the source of the message.
URL
GET http://{ip_address}:32400/log?level={level}&message={message}&source={source}&X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex user token. |
level | The log level. See Remarks below for a list of valid values. |
message | The text of the message to write to the log. |
source | A string value indicating the source of the message. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
400 | Bad request - A parameter is missing. |
401 | Unauthorized - The Plex token provided is not valid. |
Response
No response is returned by the command. The status code will indicate whether the log was written successfully.
Remarks
The log message specified using this API command will be displayed in the Plex Media Server console as well as the log file located in the data directory.
The source
parameter can be any value, such as the name of the application.
Ensure the message
and source
parameters are properly HTML encoded to ensure the values are parsed correctly.
Log level
There are several different values of log level that can be specified for this command. The table below lists the name and value for each level.
Name | Value |
---|---|
Error | 0 |
Warning | 1 |
Info | 2 |
Debug | 3 |
Verbose | 4 |
To set the log level, you would just set the level
parameter equal to the value from the above table.
Examples
curl -X GET http://{ip_address}:32400/log?level={level}&message={message}&source={source}&X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/log?level={level}&message={message}&source={source}&X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/log?level={level}&message={message}&source={source}&X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response