{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1058,"path":"api-reference/server-api-reference/c_Logger.md","title":"logger - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# logger- Global\n\nThe logger API provides inbound email actions that append messages to the email log.\n\nIt provides methods that add information, warning, and error messages. The added message has its source set to `email.<Sys ID of incoming email>`.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## logger - log\\(String msg\\)\n\nAppends the specified message to the email log.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Text to append to the email log. These should be information type messages.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis code example queries email from the sys\\_user table and then calls the appropriate logger method based on the sender information.\n\n```\nvar grUser = new GlideRecord(\"sys_user\");\ngrUser.addQuery(\"email\", email.from);\ngrUser.query();\n  if (grUser.next()) {\n    if (grUser.user_name) {\n      logger.log(\"Sender found: \" + email.from); //Append information message to the email log\n      createInc(grUser.sys_id);\n    } else {\n        logger.logWarning(\"Sender: \" + email.from + \" \" + \"found but no userID found, please take necessary actions\"); //Append warning message to the email log.\n        createInc(grUser.sys_id);\n    }\n  } else {\n      logger.logError(\"Sender is not present in the system hence action aborted\"); //Append error message to the email log.\n      current.setAbortAction(true);\n  }\n```\n\n## logger - logError\\(String msg\\)\n\nAppends the specified error message to the email log file.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Error message to append to the email log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis code example queries email from the sys\\_user table and then calls the appropriate logger method based on the sender information.\n\n```\nvar grUser = new GlideRecord(\"sys_user\");\ngrUser.addQuery(\"email\", email.from);\ngrUser.query();\n  if (grUser.next()) {\n    if (grUser.user_name) {\n      logger.log(\"Sender found: \" + email.from); //Append information message to the email log\n      createInc(grUser.sys_id);\n    } else {\n        logger.logWarning(\"Sender: \" + email.from + \" \" + \"found but no userID found, please take necessary actions\"); //Append warning message to the email log.\n        createInc(grUser.sys_id);\n    }\n  } else {\n      logger.logError(\"Sender is not present in the system hence action aborted\"); //Append error message to the email log.\n      current.setAbortAction(true);\n  }\n```\n\n## logger - logWarning\\(String msg\\)\n\nAppends the specified warning message to the email log file.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|Warning message to append to the email log|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis code example queries email from the sys\\_user table and then calls the appropriate logger method based on the sender information.\n\n```\nvar grUser = new GlideRecord(\"sys_user\");\ngrUser.addQuery(\"email\", email.from);\ngrUser.query();\n  if (grUser.next()) {\n    if (grUser.user_name) {\n      logger.log(\"Sender found: \" + email.from); //Append information message to the email log\n      createInc(grUser.sys_id);\n    } else {\n        logger.logWarning(\"Sender: \" + email.from + \" \" + \"found but no userID found, please take necessary actions\"); //Append warning message to the email log.\n        createInc(grUser.sys_id);\n    }\n  } else {\n      logger.logError(\"Sender is not present in the system hence action aborted\"); //Append error message to the email log.\n      current.setAbortAction(true);\n  }\n```\n\n"}}