facebookarchive/LogDevice

How to create/write/read a normal file ( like nginx.log ) to logdevice ?

zhengxiaochuan-3 opened this issue · 2 comments

As a normal user, I want to call the API to create/write/read a log file to logdevice. The input parameter is a normal log file name instead of logID. What should I do?
Do I need to record the mapping between log file names and log IDs?

Or

Make a full path of a log as the name of the logdevice loggroup name like :

/app1_var_log_message
/app1_export_logs_nginx_error.log
/app1_export_logs_nginx_access.log
/app2_var_log_message
/app2_export_logs_nginx_error.log
/app2_export_logs_nginx_access.log

?

Hi, I think both approach you mentioned can work. In LD the log group name has hierarchal namespace similar to file system paths, and you can use Client::getLogRangeByName() to get the LogID(s) associated with your log group as path name.

Or, If you only care about one directional mapping filename -> logID, you can use a deterministic hashing scheme that hashes a filename to one of the logIDs. Otherwise (you need reverse lookup), you can maintain the file name -> logid mapping yourself and stored in somewhere else.

Thanks a lot, I choose to maintain file name -> logid mapping in zookeeper .