Loading

Steps to Store Debug Logs in Data Extension using SSJS

Publiseringsdato: Apr 26, 2023
Beskrivelse

Data Extensions can store up to 4,000 characters in a single column. This method allows you to store debug logs even when they exceed 4,000 characters by splitting the error messages into 4,000-character segments across multiple records.

Løsning

1. Create a Data Extension to store debug logs from Contact Builder or Email Studio.

    • a. Name: Arbitrary (we'll use DEBUG_LOG here)
    • b. Data Retention Policy: Recommended to set to ON to prevent data bloat.
    • c. Columns:
      • i. Name: date, Data Type: text, Length: 30
      • ii. Name: message, Data Type: text, Length: 4000
      • iii. Name: symbol, Data Type: text, Length: 100

2. Open the Data Extension you just created and make a note of its External Key value.

3. Create your SSJS script and publish it.

<script runat="server">
Platform.Load("Core","1");

var logDe = DataExtension.Init("YOUR_DATA_EXTENSION_EXTERNAL_KEY_FROM STEP 2");
var msg = "";
var part = "";
var logMessage = "";

try{

// Your own process goes here 

} catch (error) {
msg = error;
while (msg.length > 0){
part = msg.substring(0, 4000);
logMessage = { date:Now(), message:part, symbol: "EASY_TO_IDENTIFY_MARKER_FOR_YOURSELF"};
logDe.Rows.Add(logMessage);
msg = msg.replace(part,"");
}
}

</script>

 

4. Refer to the DEBUG_LOG Data Extension to check for errors. Note: The date is stored in U.S. CST (Central Standard Time), which is 15 hours behind Japan Standard Time (JST), not Japan time.

 

 

Knowledge-artikkelnummer

000389966

 
Laster
Salesforce Help | Article