Python logging module (write log file) / basicConfig does not create log file issue(solved)

Python

logging module : write log file for exec. log in python(i think)

issue :

If "fullpath = variable + filename" as shown above, there is an issue(not create a log file).
The cause is unknown, but if " fullpath = "./log/test.log" " directly, you can see that the file is normally generated.


example 1 and issue of example 1,  solved: example 2


example 1.

import logging

def writeLogFile(logText):
    mypath = "./log"
    fullpath = mypath + "/test.log"    #mypath = "./log"
    logging.basicConfig(filename = fullpath, level=logging.DEBUG)
    logging.debug(logText)

If "fullpath = variable + filename" as shown above, there is an issue(not create a log file).

The cause is unknown, but if " fullpath = "./log/test.log" " directly, you can see that the file is normally generated.

For the above problem, I don't use basicConfig, So, I use it with example 2.


example 2 and solve.

import logging
import logging.handlers

log : ""

def initLog():
    global log
    mypath = "./log"
    fullpath = mypath + "/test.log"    #mypath = "./log"

    log = logging.getLogger('my_log')
    log.setLevel(logging.DEBUG)
    fileHandler = logging.FileHandler(fullpath)
    log.addHandler(fileHandler)


def writeLogFile(logText):
    log.debug(logText)

As shown above, log can be created as a file without any problems.


#python #logging #log #logfile #basicConfig #issue #solve #logginghandler


알뜰폰 삼성페이 교통카드 '한도 초과' 오류(등록 불가 오류) 해결방법

sk7mobile 알뜰폰 삼성페이 교통카드 등록 시, 한도 초과 문제 해결방법 skt usim 해킹 사건으로 인해 sk7mobile 알뜰폰을 사용하는 저도 usim을 바꾸고 나니 삼성페이 교통카드가 등록이 안되더라구요...  삼성페이 교통카드 기능 은...