{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":800,"path":"api-reference/server-api-reference/GlideImportLogAPI.md","title":"GlideImportLog - Scoped, Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideImportLog - Scoped, Global\n\nThe GlideImportLog API provides methods to write log entries directly to the Import Log \\[import\\_log\\] table.\n\nA GlideImportLog object is consumable by the GlideImportSetTransformer API. This object is not required for the GlideImportSetTransformer API, it enables you to associate import logs with a specific Import Set transformation.\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**Related topics**  \n\n\n[GlideImportSetRun](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideImportSetRunAPI.md)\n\n[GlideImportSetTable](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideImportSetTableAPI.md)\n\n[GlideImportSetTransformer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideImportSetTransformerAPI.md)\n\n[GlideImportSetTransformMap](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideImportSetTransformMapAPI.md)\n\n[GlideTransformLog](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideTransformLogAPI.md)\n\n## GlideImportLog - GlideImportLog\\(GlideImportSetRun importSetRun, String source\\)\n\nInstantiates a GlideImportLog object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|importSetRun|GlideImportSetRun|Optional. Import Set Run record on which all logs are to be associated with.|\n|source|String|Optional. Source field value attached to the Import Log record that defines where in the Import Set process this message was logged from. For example, Loading could represent loading step, Cleanup could represent during the cleanup after the transform, and so on.|\n\nExample without optional source parameter.\n\n```\nvar importSetRun = new GlideImportSetRun();\nvar importLog = new GlideImportLog(importSetRun);\n\n```\n\nExample using optional source parameter.\n\n```\nvar importSetRun = new GlideImportSetRun();\nvar importLog = new GlideImportLog(importSetRun, 'Scripted ImportSetTransformer');\n\n```\n\n## GlideImportLog - error\\(String message, String source\\)\n\nLogs a message of type Error to the Import Log \\[import\\_log\\] table.\n\n### GlideImportLog\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Log message. Maximum length 4000 characters.|\n|source|String|Optional. Source field value attached to the Import Log record that defines where in the Import Set process this message was logged from. For example, Loading could represent loading step, Cleanup could represent during the cleanup after the transform, and so on.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\nvar importLog = new GlideImportLog();\nimportLog.error('Error executing transform');\n\n```\n\n## GlideImportLog - getImportRunHistory\\(\\)\n\nReturns a sys\\_id of the Import Run record associated with this Import Log.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Sys\\_id of an Import Set Run record from the Transform History \\[sys\\_import\\_set\\_run\\] table.|\n\n```\nvar importSet = new GlideRecord('sys_import_set');\nimportSet.name = 'Scripted Import Set';\nimportSet.short_description = 'Import set from scripted rest api';\nimportSet.table_name = importSetTableName;\nvar importSetID = importSet.insert();\nvar importLog = new GlideImportLog();\nvar transformer = new GlideImportSetTransformer();\ntransformer.setLogger(importLog);\ntransformer.transformAllMaps(importSet);\nvar importRunSysId = importLog.getImportRunHistory();\n\n```\n\n## GlideImportLog - info\\(String message, String source\\)\n\nLogs a message of type Info to the Import Log \\[import\\_log\\] table.\n\n### GlideImportLog\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Log message. Maximum length 4000 characters.|\n|source|String|Optional. Source field value attached to the Import Log record that defines where in the Import Set process this message was logged from. For example, Loading could represent loading step, Cleanup could represent during the cleanup after the transform, and so on.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\nvar importLog = new GlideImportLog();\nimportLog.info('Successfully executed transform');\n\n```\n\n## GlideImportLog - setImportRunHistory\\(String importRunHistory\\)\n\nAssociates the GlideImportLog object with a specific Import Set Run record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|importRunHistory|String|The sys\\_id of a record from the Transform History \\[sys\\_import\\_set\\_run\\] table.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar importRunSysId = '4aa3a8d55ba10010953330ad5981c79f';\nvar importLog = new GlideImportLog();\nimportLog.setImportRunHistory(importRunSysId);\n\n```\n\n## GlideImportLog - warn\\(String message, String source\\)\n\nLogs a message of type Warn to the Import Log \\[import\\_log\\] table.\n\n### GlideImportLog\n\n|Name|Type|Description|\n|----|----|-----------|\n|message|String|Log message. Maximum length 4000 characters.|\n|source|String|Optional. Source field value attached to the Import Log record that defines where in the Import Set process this message was logged from. For example, Loading could represent loading step, Cleanup could represent during the cleanup after the transform, and so on.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\nvar importLog = new GlideImportLog();\nimportLog.warn('Transform taking longer than expected.');\n\n```\n\n"}}