Question related to this problem was not answered by anyone
I tried implementing error logging using python in azure data bricks. If i try the below code in python(pycharm) it is working as expected. But when i try the same code in azure databricks(python) it is not creating a file and not writing any contents into the file. I tried creating a file in azure data lake gen2. i have given the path with mount point of data lake store gen2.
Can you please help why the python code is not working as expected in azure data bricks(python)
# importing module
import logging
dbutils.fs.mkdirs('/dbfs/mnt/sales/region/country/sample/newfile.txt')
# Create and configure logger
logging.basicConfig(filename="/dbfs/mnt/sales/region/
country/sample/newfile.txt",
format='%(asctime)s %(message)s',
filemode='a')
# Creating an object
logger = logging.getLogger()
# Setting the threshold of logger to DEBUG
logger.setLevel(logging.DEBUG)
# Test messages
logger.debug("Harmless debug Message")
logger.info("Just an information")
logger.warning("Its a Warning")
logger.error("Did you try to divide by zero")
logger.critical("Internet is down")
If i open the file i expect the output to be like below which is
happening with python but the same is not working with azure data
bricks(python)
2019-06-06 00:19:23,881 Harmless debug Message
2019-06-06 00:19:23,881 Just an information
2019-06-06 00:19:23,881 Its a Warning
2019-06-06 00:19:23,881 Did you try to divide by zero
2019-06-06 00:19:23,881 Internet is down
2019-06-06 00:19:33,447 Harmless debug Message
2019-06-06 00:19:33,447 Just an information
2019-06-06 00:19:33,447 Its a Warning
2019-06-06 00:19:33,447 Did you try to divide by zero
2019-06-06 00:19:33,447 Internet is down