1--- 2title: Debug logging 3--- 4 5By default ExoPlayer only logs errors. To log player events, the `EventLogger` 6class can be used. The additional logging it provides can be helpful for 7understanding what the player is doing, as well as for debugging playback 8issues. `EventLogger` implements `AnalyticsListener`, so registering an instance 9with an `ExoPlayer` is easy: 10 11``` 12player.addAnalyticsListener(new EventLogger(trackSelector)); 13``` 14{: .language-java} 15 16Passing the `trackSelector` enables additional logging, but is optional and so 17`null` can be passed instead. 18 19The easiest way to observe the log is using Android Studio's [logcat tab][]. You 20can select your app as debuggable process by the package name ( 21`com.google.android.exoplayer2.demo` if using the demo app) and tell the logcat 22tab to log only for that app by selecting 'show only selected application'. It's 23possible to further filter the logging with the expression 24`EventLogger|ExoPlayerImpl`, to get only logging from `EventLogger` and the 25player itself. 26 27An alternative to using Android Studio's logcat tab is to use the console. For 28example: 29 30~~~ 31adb logcat EventLogger:* ExoPlayerImpl:* *:s 32~~~ 33{: .language-shell} 34 35### Player information ### 36 37The `ExoPlayerImpl` class delivers two important lines about the player version, 38the device and OS the app is running on and the modules of ExoPlayer that have 39been loaded: 40 41``` 42ExoPlayerImpl: Release 2cd6e65 [ExoPlayerLib/2.12.0] [marlin, Pixel XL, Google, 26] [goog.exo.core, goog.exo.ui, goog.exo.dash] 43ExoPlayerImpl: Init 2e5194c [ExoPlayerLib/2.12.0] [marlin, Pixel XL, Google, 26] 44``` 45 46### Playback state ### 47 48Player state changes are logged in lines like the ones below: 49 50``` 51EventLogger: playWhenReady [eventTime=0.00, mediaPos=0.00, window=0, true, USER_REQUEST] 52EventLogger: state [eventTime=0.01, mediaPos=0.00, window=0, BUFFERING] 53EventLogger: state [eventTime=0.93, mediaPos=0.00, window=0, period=0, READY] 54EventLogger: isPlaying [eventTime=0.93, mediaPos=0.00, window=0, period=0, true] 55EventLogger: playWhenReady [eventTime=9.40, mediaPos=8.40, window=0, period=0, false, USER_REQUEST] 56EventLogger: isPlaying [eventTime=9.40, mediaPos=8.40, window=0, period=0, false] 57EventLogger: playWhenReady [eventTime=10.40, mediaPos=8.40, window=0, period=0, true, USER_REQUEST] 58EventLogger: isPlaying [eventTime=10.40, mediaPos=8.40, window=0, period=0, true] 59EventLogger: state [eventTime=20.40, mediaPos=18.40, window=0, period=0, ENDED] 60EventLogger: isPlaying [eventTime=20.40, mediaPos=18.40, window=0, period=0, false] 61``` 62 63In this example playback starts 0.93 seconds after the player is prepared. The 64user pauses playback after 9.4 seconds, and resumes playback one second later at 6510.4 seconds. Playback ends ten seconds later at 20.4 seconds. The common 66elements within the square brackets are: 67 68* `[eventTime=float]`: The wall clock time since player creation. 69* `[mediaPos=float]`: The current playback position. 70* `[window=int]`: The current window index. 71* `[period=int]`: The current period in that window. 72 73The final elements in each line indicate the value of the state being reported. 74 75### Media tracks ### 76 77Track information is logged when the available or selected tracks change. This 78happens at least once at the start of playback. The example below shows track 79logging for an adaptive stream: 80 81``` 82EventLogger: tracks [eventTime=0.30, mediaPos=0.00, window=0, period=0, 83EventLogger: MediaCodecVideoRenderer [ 84EventLogger: Group:0, adaptive_supported=YES [ 85EventLogger: [X] Track:0, id=133, mimeType=video/avc, bitrate=261112, codecs=avc1.4d4015, res=426x240, fps=30.0, supported=YES 86EventLogger: [X] Track:1, id=134, mimeType=video/avc, bitrate=671331, codecs=avc1.4d401e, res=640x360, fps=30.0, supported=YES 87EventLogger: [X] Track:2, id=135, mimeType=video/avc, bitrate=1204535, codecs=avc1.4d401f, res=854x480, fps=30.0, supported=YES 88EventLogger: [X] Track:3, id=160, mimeType=video/avc, bitrate=112329, codecs=avc1.4d400c, res=256x144, fps=30.0, supported=YES 89EventLogger: [ ] Track:4, id=136, mimeType=video/avc, bitrate=2400538, codecs=avc1.4d401f, res=1280x720, fps=30.0, supported=NO_EXCEEDS_CAPABILITIES 90EventLogger: ] 91EventLogger: ] 92EventLogger: MediaCodecAudioRenderer [ 93EventLogger: Group:0, adaptive_supported=YES_NOT_SEAMLESS [ 94EventLogger: [ ] Track:0, id=139, mimeType=audio/mp4a-latm, bitrate=48582, codecs=mp4a.40.5, channels=2, sample_rate=22050, supported=YES 95EventLogger: [X] Track:1, id=140, mimeType=audio/mp4a-latm, bitrate=127868, codecs=mp4a.40.2, channels=2, sample_rate=44100, supported=YES 96EventLogger: ] 97EventLogger: ] 98EventLogger: ] 99``` 100 101In this example, the player has selected four of the five available video 102tracks. The fifth video track is not selected because it exceeds the 103capabilities of the device, as indicated by `supported=NO_EXCEEDS_CAPABILITIES`. 104The player will adapt between the selected video tracks during playback. When 105the player adapts from one track to another, it's logged in a line like the one 106below: 107 108``` 109EventLogger: downstreamFormat [eventTime=3.64, mediaPos=3.00, window=0, period=0, id=134, mimeType=video/avc, bitrate=671331, codecs=avc1.4d401e, res=640x360, fps=30.0] 110``` 111 112This log line indicates that the player switched to the 640x360 resolution video 113track three seconds into the media. 114 115### Decoder selection ### 116 117In most cases ExoPlayer renders media using a `MediaCodec` acquired from the 118underlying platform. When a decoder is initialized, this is logged in lines like 119the ones below: 120 121``` 122EventLogger: videoDecoderInitialized [0.77, 0.00, window=0, period=0, video, OMX.qcom.video.decoder.avc] 123EventLogger: audioDecoderInitialized [0.79, 0.00, window=0, period=0, audio, OMX.google.aac.decoder] 124``` 125 126[logcat tab]: https://developer.android.com/studio/debug/am-logcat 127