IBM QRadar SOAR

 View Only

 Log on another file than app.log

Lucian Sipos's profile image
Lucian Sipos posted Tue January 21, 2025 11:53 AM

Hello all

I am trying to log my responses in another file, different than the default app.log.

Below you can take a look at how I'm trying to do it:

import logging
from logging.handlers import RotatingFileHandler

PACKAGE_NAME = "artifact_searcher"
FN_NAME = "artifact_searcher"

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

handler = RotatingFileHandler(
'/resilient_venv/.resilient/logs/artifact_searcher/artifact_searcher.log',
maxBytes=10 * 1024 * 1024,
backupCount=10)

formatter = logging.Formatter('%(asctime)s - %(module)s - %(funcName)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)

logger.addHandler(handler)


class ArgumentParser(resilient.ArgumentParser):
def __init__(self, config_file=None):
super(ArgumentParser, self).__init__(config_file=config_file)


parser = ArgumentParser(config_file=resilient.get_config_file())
opts = parser.parse_args()
resilient_client = resilient.get_client(opts)

[OTHER CODE]

The problem is that no log is being written in the custom file. Yields in my function are still visibile in app.log (and it's expected behaviour) but no other than that.

Is there any standard/specific procedure to achieve this? Eventually, how users of the community to this?


Thanks

Mohamad islam Hamadieh's profile image
Mohamad islam Hamadieh

longshot but dose your app/script have the privileges to write on the specified path?