---
sourceDocument: Australia API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/de-DE/api-reference

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GSLog - Scoped, Global

# GSLog - Scoped, Global {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 Minuten Lesedauer

GSLog is a script include that simplifies script logging and debugging by implementing levels of log output, selectable by per-caller identified sys_properties values.

Logs generated using the GSLog API are logged in the System Logs. Specifically, you can find System Logs in the UI by navigating to AllSystem LogsSystem Log. You can choose to view all logs or specific log types like Application Logs, Errors, Script Log Statements, and so on under this menu item. Filtering the Source column in the All logs view can
help locate your entries faster.

Logs can be at the level of debug, info, notice, warning, err, or crit (after BSD syslog.h and followers). The default logging level is notice, so levels should be chosen accordingly.

Use for any server-side script where you want to implement event
logging.

For more information, see [Debugging scripts](https://www.servicenow.com/docs/8w1BTwGn88Te96jasXtlkg "Debug scripts using session logs and ServiceNow AI Platform debugging tools such as a walk-through script debugger and error messages that display in the UI.").

## GSLog -- GSLog() {#ariaid-title2}

Instantiates a GSLog object.
{#gsLog-GSLog__table_bln_fyx_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| traceProperty | String | System property that contains a value indicating the level at or above which messages will be written to the log. |
| caller | String | Name of the script calling the logger. |
[Tabelle : 1. Parameters]

{#gsLog-GSLog__table_bln_fyx_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA");

## GSLog -- debugOn() {#ariaid-title3}

Determines if debug is turned on.
{#gsLog-debugOn__table_jyg_zmx_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 2. Parameters]

{#gsLog-debugOn__table_jyg_zmx_15b} {#gsLog-debugOn__table_kyg_zmx_15b__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether debug is on or off. Valid values: * true: Debug is on. * false: Debug is off. {#gsLog-debugOn__ul_zcc_gxx_15b} |
[Tabelle : 3. Returns]

{#gsLog-debugOn__table_kyg_zmx_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.setLevel("debug");
    gs.print(gl.debugOn());

Output:

    *** Script : true

## GSLog -- getLevel(String level) {#ariaid-title4}

Returns the log level.
{#gsLog-getLevel_S__table_tpq_j4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| level | String | Optional. Log level. |
[Tabelle : 4. Parameters]

{#gsLog-getLevel_S__table_tpq_j4x_15b} {#gsLog-getLevel_S__table_upq_j4x_15b__entry__2}

| Type | Description |
|-|-|
| String | Log level. |
[Tabelle : 5. Returns]

{#gsLog-getLevel_S__table_upq_j4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.setLevel("debug");
    gs.print(gl.getLevel());

Output:

    *** Script: debug

## GSLog -- initialize(String traceProperty, String caller) {#ariaid-title5}

Called by the Prototype JavaScript Framework during object creation to initialize a new
instance of this class. Provide the input parameters, but do not call this method
directly.
{#gsLog-initialize_S_S__table_gjz_1nx_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| traceProperty | String | System property that contains a value indicating the level at or above which messages will be written to the log. |
| caller | String | Name of the script calling the logger. |
[Tabelle : 6. Parameters]

{#gsLog-initialize_S_S__table_gjz_1nx_15b} {#gsLog-initialize_S_S__table_hjz_1nx_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 7. Returns]

{#gsLog-initialize_S_S__table_hjz_1nx_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA");

## GSLog -- log(String level, String msg) {#ariaid-title6}

Logs a message at the specified level.
{#gsLog-log_S_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| level | String | Log level. |
| msg | String | Message to write to the log. |
[Tabelle : 8. Parameters]

{#gsLog-log_S_S__table_sz4_m4x_15b} {#gsLog-log_S_S__table_jdw_k4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 9. Returns]

{#gsLog-log_S_S__table_jdw_k4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.log("debug", "debug message");

## GSLog -- logAlert(String msg) {#ariaid-title7}

Logs alert events.
{#gsLog-logAlert_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 10. Parameters]

{#gsLog-logAlert_S__table_sz4_m4x_15b} {#gsLog-logAlert_S__table_oh5_l4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 11. Returns]

{#gsLog-logAlert_S__table_oh5_l4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logAlert("This is an alert");

Output:

    *** Script [TaskSLA]: This is an alert

## GSLog -- logCrit(String msg) {#ariaid-title8}

Logs critical events.
{#gsLog-logCrit_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 12. Parameters]

{#gsLog-logCrit_S__table_sz4_m4x_15b} {#gsLog-logCrit_S__table_tz4_m4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 13. Returns]

{#gsLog-logCrit_S__table_tz4_m4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logCrit("This is a critical message");

Output:

    *** Script [TaskSLA]: This is a critical message

## GSLog -- logDebug(String msg) {#ariaid-title9}

Logs debug events.
{#gsLog-logDebug_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 14. Parameters]

{#gsLog-logDebug_S__table_sz4_m4x_15b} {#gsLog-logDebug_S__table_tz4_m4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 15. Returns]

{#gsLog-logDebug_S__table_tz4_m4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logDebug("This is a debug message");

Output:

    *** Script [TaskSLA]: This is a debug message

## GSLog -- logEmerg(String msg) {#ariaid-title10}

Logs emergency events.
{#gsLog-logEmerg_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 16. Parameters]

{#gsLog-logEmerg_S__table_sz4_m4x_15b} {#gsLog-logEmerg_S__table_fbm_n4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 17. Returns]

{#gsLog-logEmerg_S__table_fbm_n4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logEmerg("This is an emergency message");

Output:

    *** Script  [TaskSLA ] : This is an emergency message

## GSLog -- logErr(String msg) {#ariaid-title11}

Logs error events.
{#gsLog-logErr_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 18. Parameters]

{#gsLog-logErr_S__table_sz4_m4x_15b} {#gsLog-logErr_S__table_kzj_44x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 19. Returns]

{#gsLog-logErr_S__table_kzj_44x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logErr("This is an error message");

Output:

    *** Script [TaskSLA]: This is an error message

## GSLog -- logInfo(String msg) {#ariaid-title12}

Logs information events.
{#gsLog-logInfo_S__table_e4f_p4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 20. Parameters]

{#gsLog-logInfo_S__table_e4f_p4x_15b} {#gsLog-logInfo_S__table_f4f_p4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 21. Returns]

{#gsLog-logInfo_S__table_f4f_p4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logInfo("This is an info message");

## GSLog -- logNotice(String msg) {#ariaid-title13}

Logs notice events.
{#gsLog-logNotice_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 22. Parameters]

{#gsLog-logNotice_S__table_sz4_m4x_15b} {#gsLog-logNotice_S__table_kdc_q4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 23. Returns]

{#gsLog-logNotice_S__table_kdc_q4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logNotice("This is a notice");

Output:

    *** Script [TaskSLA]: This is a notice

## GSLog -- logWarning(String msg) {#ariaid-title14}

Logs warning events.
{#gsLog-logWarning_S__table_sz4_m4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | Message to write to the log. |
[Tabelle : 24. Parameters]

{#gsLog-logWarning_S__table_sz4_m4x_15b} {#gsLog-logWarning_S__table_fwt_s4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 25. Returns]

{#gsLog-logWarning_S__table_fwt_s4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.logWarning("This is a warning message");

Output:

    *** Script [TaskSLA]: This is a warning message

## GSLog -- setLevel(String level) {#ariaid-title15}

Sets the log level.
{#gsLog-setLevel_S__table_tpq_j4x_15b__entry__3}

| Name | Type | Description |
|-|-|-|
| level | String | Log level to set. |
[Tabelle : 26. Parameters]

{#gsLog-setLevel_S__table_tpq_j4x_15b} {#gsLog-setLevel_S__table_fwt_s4x_15b__entry__2}

| Type | Description |
|-|-|
| None |   |
[Tabelle : 27. Returns]

{#gsLog-setLevel_S__table_fwt_s4x_15b}  

    var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA"); 
    gl.setLevel("debug");


