AFNetworkActivityLogger alternatives and similar libraries
Based on the "Logging" category.
Alternatively, view AFNetworkActivityLogger alternatives based on common mentions on social networks and blogs.
-
CocoaLumberjack
A fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS -
XCGLogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number. -
GodEye
Automaticly display Log,Crash,Network,ANR,Leak,CPU,RAM,FPS,NetFlow,Folder and etc with one line of code based on Swift. Just like God opened his eyes -
TinyConsole
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible. -
CleanroomLogger
CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant -
KZLinkedConsole
Clickable links in your Xcode console, so you never wonder which class logged the message. -
Diagnostics
Allow users to easily share Diagnostics with your support team to improve the flow of fixing bugs. -
JustLog
DISCONTINUED. JustLog brings logging on iOS to the next level. It supports console, file and remote Logstash logging via TCP socket with no effort. Support for logz.io available. -
LxDBAnything
Automate box any value! Print log without any format control symbol! Change debug habit thoroughly! -
XLFacility
DISCONTINUED. Elegant and extensive logging facility for OS X & iOS (includes database, Telnet and HTTP servers) -
Twitter Logging Service
Twitter Logging Service is a robust and performant logging framework for iOS clients -
Loggerithm
DISCONTINUED. A lightweight Swift logger, uses print in development and NSLog in production. Support colourful and formatted output. -
puree
DISCONTINUED. [Obsoleted] A log collector for iOS (new version! -> https://github.com/cookpad/Puree-Swift) -
Logkit
An efficient logging library for OS X, iOS, watchOS, and tvOS – written in Swift. Log to console, file, HTTP service, or your own endpoint. Simple to get started, but smartly customizable. -
Atlantis
A powerful input-agnostic swift logging framework made to speed up development with maximum readability. -
CleanroomASL
DISCONTINUED. A Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as "the console") -
TraceLog
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS. -
ReflectedStringConvertible
A protocol that allows any class to be printed as if it were a struct or a JSON object. -
Spy
Spy is a flexible, lightweight, multiplatform logging utility written in pure Swift. It allows to log with different levels and on different channels. You can define what levels and channels actually are.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of AFNetworkActivityLogger or a related project?
README
AFNetworkActivityLogger
AFNetworkActivityLogger
is an extension for AFNetworking 3.0 that logs network requests as they are sent and received.
AFNetworkActivityLogger
listensAFNetworkingTaskDidStartNotification
andAFNetworkingTaskDidFinishNotification
notifications, which are posted by AFNetworking as session tasks are started and finish. For further customization of logging output, users are encouraged to implement desired functionality by creating new objects that conform toAFNetworkActivityLoggerProtocol
.
2.x -> 3.x Migration
3.0.0 featured the following breaking API changes:
- The log
level
property is now found on the individual unique loggers, rather than the shared logger. This allows for more advanced customization options for logging level. - The
filterPredicate
property is now found on the individual unique loggers, rather than the shared logger. This allows for more advanced customization options for logging specific requests.
Usage
Add the following code to AppDelegate.m -application:didFinishLaunchingWithOptions:
:
[[AFNetworkActivityLogger sharedLogger] startLogging];
Now all NSURLSessionTask
objects created by an AFURLSessionManager
will have their request and response logged to the console, a la:
GET http://example.com/foo/bar.json
200 http://example.com/foo/bar.json [0.1860 s]
If the default logging level is too verbose—say, if you only want to know when requests fail—then changing it is as simple as:
[[AFNetworkActivityLogger sharedLogger] setLevel:AFLoggerLevelError];
Logging Levels
By default, the shared logger is configured with an AFNetworkActivityConsoleLogger
with a debug level set to AFLoggerLevelInfo
. To change the level, simply access the logger through the loggers
property, and adjust the level. The following levels are provided:
AFLoggerLevelOff
: Do not log requests or responses.AFLoggerLevelDebug
:Logs HTTP method, URL, header fields, & request body for requests, and status code, URL, header fields, response string, & elapsed time for responses.AFLoggerLevelInfo
: Logs HTTP method & URL for requests, and status code, URL, & elapsed time for responses.AFLoggerLevelError
: Logs HTTP method & URL for requests, and status code, URL, & elapsed time for responses, but only for failed requests.
Filtering Requests
To limit the requests that are logged by a unique logger, each object that conforms to AFNetworkActivityLoggerProtocol
has a filterPredicate
property. If the predicate returns true, the request will not be forwarded to the logger. For example, a custom file logger could be created that only logs requests for http://httpbin.org
, while a console logger could be used to log all errors in the application.
AFNetworkActivityConsoleLogger *testLogger = [AFNetworkActivityConsoleLogger new];
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(NSURLRequest * _Nonnull request, NSDictionary<NSString *,id> * _Nullable bindings) {
return !([[request URL] baseURL] isEqualToString:@"httpbin.org"])
}];
[testLogger setFilterPredicate:predicate];
Custom Loggers
By default, the shared logger is configured with an AFNetworkActivityConsoleLogger
.
To create a custom logger, create a new object that conforms to AFNetworkActivityLoggerProtocol
, and add it to the shared logger. Be sure and configure the proper default logging level.
License
AFNetworkActivityLogger is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the AFNetworkActivityLogger README section above
are relevant to that project's source code only.