---
schema_version: "1"
id: 5a5a8c2cda6b400c109bb737ffcc66df005a19f3b4d19297ecf31586c575992d
title: EndFileLog.ds
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/b2c-commerce/guides/inventory/b2c-end-file-log-ds.md
canonical_url: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-end-file-log-ds.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b4c77414c8e5056e97d6eb39a7e033479b3a2f1b91e3f39450f2ad5c14d4bc11
products:
  - Composable Storefront
  - Salesforce APIs
---
# EndFileLog.ds

Review the EndFileLog.ds referenced script files when scheduling inventory imports.

**note:** This code is provided as a sample. It isn't a supported part of the SiteGenesis application.

```
/***********************************************************
 * Name: EndFileLog.ds
 *
 * Description:
 *  Resets FileLogger to stop writing all logging events to file.
 *  This replaces the FileLogger with a normal logger in the pdict.
 *
 * @input sampleLogger   : Object
 * @output sampleLogger  : Object
 * @output sampleError   : Object
 *
 ***********************************************************/
importScript("bc_sample:library/common/libContext.ds");
importScript("bc_sample:library/utility/exception/libsampleException.ds");
importScript("bc_sample:library/utility/logging/libLog.ds");



function execute(pdict: PipelineDictionary): Number {



    var _context: Context = new Context("EndFileLog.ds");
    var _logger: Log = pdict.sampleLogger;

    try {

        if (empty(_logger)) {

            throw new sampleException(_context,
                "No Log instance found. " +
                "Make sure the corresponding 'BeginFileLog' pipelet was set on this pipeline.");
        }

        _logger.debug(_context, "Now stopped logging to file.");

        if (FileLog.prototype.isPrototypeOf(_logger)) {

            // resets logger to the original instance
            pdict.sampleLogger = _logger.getBaseLogger();
        } else {

            // resets logwriter on logger
            _logger.setLogWriter(null);
            pdict.sampleLogger = _logger;
        }
    } catch (e) {

        // Call into error handler
        _logger.error(_context, "Error occurred processing pipelet: " + e.message);

        // wrap error into custom exception
        var exception: sampleException = new sampleException(_context, "Error occured in pipelet", e);
        pdict.sampleError = exception;

        return PIPELET_ERROR;
    }

    return PIPELET_NEXT;
}
```
