How to send log statements over the network through CocoaLumberjack?
Asked Answered
J

1

6

In the summary of CocoaLumberjack it is mentioned that "Lumberjack is Powerful", and then "Want more? Create your own loggers (it's easy) and send your log statements over the network." So, I wonder how can we send log statements over the network through CocoaLumberjack? Is there an existing interface to do this? Or must we do it by our own code? Could somebody give me sample code to this?

Jammie answered 13/8, 2014 at 9:37 Comment(1)
I found an awesome library that does the file upload over network in background. github.com/pushd/BackgroundUpload-CocoaLumberjackEvensong
P
5

To answer your question, there isn't anything built-in for sending logs over the network.

You can take the highroad and:

OR

  • read the logs from a file logger and sending those over the network. Use the DDFileLogger logFileManager to get the sortedLogFilePaths (list of paths to the log files). Those files are plain text and can be read like any other file.
Plasmodium answered 18/8, 2014 at 12:59 Comment(4)
Do you know of any good strategy for sending the log files over the network? For example, you obviously don't want to be doing it to often, but what might be a good interval or event to trigger a log upload?Misdemean
@Misdemean I would recommend taking a look at the Demos workspace that comes with CocoaLumberjack, especially the CoreDataLogger project. They present some ideas on handling batching and update frequency/intervals for trigging log uploads that I think would also apply to a network logger.Dimpledimwit
@Misdemean You might use a similar approach with analytics frameworks like Google Analytics. They send over batches of information after app start or app return from background or before the app is closed.Plasmodium
Thanks, I will probably use the Core Data logger in combination with some of the app lifecycle events.Misdemean

© 2022 - 2024 — McMap. All rights reserved.